Esempio n. 1
0
        protected virtual Process CreateProcess(DevEnv devenv, IEnumerable <string> args, bool start = true)
        {
            var psi = new ProcessStartInfo(devenv.ProductPath)
            {
                RedirectStandardOutput = true,
            };

            if (args != null)
            {
                foreach (var arg in args)
                {
                    psi.ArgumentList.Add(arg);
                }
            }

            var process = new Process()
            {
                StartInfo = psi
            };

            if (start)
            {
                process.Start();
            }

            return(process);
        }
Esempio n. 2
0
        void StartServerAndClient(DevEnv devenv, TextWriter output)
        {
            var args = new List <string>(Descriptor.ExtraArguments);

            // If no sln or folder path was provided, use the current directory
            if (!args.Any())
            {
                args.Add(Directory.GetCurrentDirectory());
            }

            if (Descriptor.IsExperimental)
            {
                args.AddRange(new[] { "/rootSuffix", "Exp" });
            }

            args.Add("/server");

            output.WriteLine($"Starting server: {devenv.ProductPath} {string.Join(" ", args)}");

            Server = CreateProcess(devenv, args);

            foreach (var line in ReadOutputLines(Server))
            {
                output.WriteLine("[devenv] " + line);

                if (line.LastIndexOf(JoinToken) is int joinIndexOf && joinIndexOf != -1)
                {
                    StartClient(devenv, line.Substring(joinIndexOf + JoinToken.Length), output);
                }
            }
        }
Esempio n. 3
0
        public Task ExecuteAsync(DevEnv devenv, TextWriter output)
        {
            if (string.IsNullOrEmpty(Descriptor.WorkspaceId))
            {
                StartServerAndClient(devenv, output);
            }
            else
            {
                StartClient(devenv, Descriptor.WorkspaceId, output);
            }

            return(Task.CompletedTask);
        }
Esempio n. 4
0
        void StartClient(DevEnv devenv, string workspaceId, TextWriter output)
        {
            var args = new List <string>();

            if (Descriptor.IsExperimental)
            {
                args.AddRange(new[] { "/rootSuffix", "Exp" });
            }

            args.Add("/client");
            args.AddRange(new[] { "/joinworkspace", $"vsls:?workspaceId={workspaceId}&remoteJoin=true" });

            output.WriteLine($"Starting client: {devenv.ProductPath} {string.Join(" ", args)}");

            Client = CreateProcess(devenv, args);
        }