コード例 #1
0
        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
        }
コード例 #2
0
        public static void InitializeDefault(
            InteractiveInstallationPaths installationPaths = null)
        {
            if (Default != null)
            {
                throw new InvalidOperationException("InitializeDefault has already been called");
            }

            Default = new InteractiveInstallation(installationPaths);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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> ());
        }
コード例 #5
0
        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
        }