public static void LaunchClientAppForDebugging(Agent agent) { #if DEBUG if (!Debugger.IsAttached) { return; } var clientAssemblyLocation = Assembly.GetExecutingAssembly().Location; var agentType = agent.ClientSessionUri.AgentType; InteractiveInstallation.InitializeDefault(null); var clientPath = InteractiveInstallation .Default .LocateClientApplication(agent.ClientSessionUri.SessionKind); if (string.IsNullOrEmpty(clientPath)) { return; } var connectUri = new ClientSessionUri( agent.Identity.AgentType, agent.ClientSessionUri.SessionKind, agent.Identity.Host, agent.Identity.Port); if (HostEnvironment.OS == HostOS.macOS) { var executableName = Directory.GetFiles( Path.Combine(clientPath, "Contents", "MacOS")) [0]; clientPath = Path.Combine(clientPath, "Contents", "MacOS", executableName); } Exec.Log += (sender, e) => { if (e.ExitCode == null) { Log.Debug(TAG, $"Exec[{e.ExecId}] ({e.Flags}): {e.Arguments}"); } else { Log.Debug(TAG, $"Exec[{e.ExecId}] exited: {e.ExitCode}"); } }; Exec.RunAsync( segment => Debug.WriteLine($"!! {segment.Data.TrimEnd ()}"), clientPath, connectUri).ContinueWith(task => { if (task.Exception != null) { Log.Error(TAG, task.Exception); } }); #endif }
public static void InitializeDefault( InteractiveInstallationPaths installationPaths = null) { if (Default != null) { throw new InvalidOperationException("InitializeDefault has already been called"); } Default = new InteractiveInstallation(installationPaths); }
public static void InitializeDefault( bool isMac, string buildPath, InteractiveInstallationPaths installationPaths = null) { if (Default != null) { throw new InvalidOperationException("InitializeDefault has already been called"); } Default = new InteractiveInstallation(isMac, buildPath, installationPaths); }
static IReadOnlyList <WorkbookAppInstallation> LocateWorkbookApps() { FilePath repoRoot = DevEnvironment.RepositoryRootDirectory; if (!repoRoot.IsNull && repoRoot.DirectoryExists) { searchPaths.Add(repoRoot.Combine("_build")); } var manifestFile = InteractiveInstallation .LocateFiles(searchPaths, "workbookapps.json") .FirstOrDefault(); if (manifestFile == null) { Log.Warning(TAG, "Unable to locate workbook apps manifest file:"); foreach (var path in searchPaths) { Log.Warning(TAG, $" {path}"); } return(Array.Empty <WorkbookAppInstallation> ()); } Log.Info(TAG, $"Loading workbook apps from manifest: {manifestFile}"); var manifestDirectory = Path.GetDirectoryName(manifestFile); try { using (var reader = new StreamReader(manifestFile)) return(JObject .Load(new JsonTextReader(reader)) .Children <JProperty> () .Select(app => { try { return FromManifestObject( manifestDirectory, app.Name, (JObject)app.Value); } catch (Exception e) { Log.Error(TAG, e); return null; } }) .Where(app => app != null) .OrderBy(app => app.order) .ToArray()); } catch (Exception e) { Log.Error(TAG, $"Unable to parse JSON for {manifestFile}", e); } return(Array.Empty <WorkbookAppInstallation> ()); }
public static void LaunchClientAppForDebugging(Agent agent) { #if DEBUG if (!Debugger.IsAttached) { return; } var clientAssemblyLocation = Assembly.GetExecutingAssembly().Location; var buildDepth = 5; var agentType = agent.ClientSessionUri.AgentType; // The Mac executable is more deeply nested, so we need to go up a little further // to get the base build path. if (agentType == AgentType.MacMobile || agentType == AgentType.MacNet45) { buildDepth = 7; } var buildDir = clientAssemblyLocation; for (var i = 0; i < buildDepth; i++) { buildDir = Path.GetDirectoryName(buildDir); } InteractiveInstallation.InitializeDefault( isMac: Environment.OSVersion.Platform == PlatformID.Unix, buildPath: buildDir); var clientPath = InteractiveInstallation .Default .LocateClientApplication(agent.ClientSessionUri.SessionKind); if (string.IsNullOrEmpty(clientPath)) { return; } var connectUri = new ClientSessionUri( agent.Identity.AgentType, agent.ClientSessionUri.SessionKind, agent.Identity.Host, agent.Identity.Port); if (InteractiveInstallation.Default.IsMac) { var executableName = Directory.GetFiles( Path.Combine(clientPath, "Contents", "MacOS")) [0]; clientPath = Path.Combine(clientPath, "Contents", "MacOS", executableName); } Exec.Log += (sender, e) => { if (e.ExitCode == null) { Log.Debug(TAG, $"Exec[{e.ExecId}] ({e.Flags}): {e.Arguments}"); } else { Log.Debug(TAG, $"Exec[{e.ExecId}] exited: {e.ExitCode}"); } }; Exec.RunAsync( segment => Debug.WriteLine($"!! {segment.Data.TrimEnd ()}"), clientPath, connectUri).ContinueWith(task => { if (task.Exception != null) { Log.Error(TAG, task.Exception); } }); #endif }