Beispiel #1
0
        public RunResult Stop(DebuggingTargetViewModel target)
        {
            if (target.CurrentProcess == null)
            {
                return(new RunResult
                {
                    Message = "Process was already killed"
                });
            }

            try
            {
                // Don't ask nicely, just kill the process, we want to be fast here.
                target.CurrentProcess.Kill();
            }
            catch (Exception)
            {
                return(new RunResult
                {
                    Message = $"Could not kill process {target.CurrentProcessId}"
                });
            }

            return(new RunResult());
        }
Beispiel #2
0
        private bool RunSingleTarget(bool debug, DebuggingTargetViewModel target, Process visualStudioProcess, out RunResult run)
        {
            var psi = new ProcessStartInfo(target.Executable, target.CommandLineArguments)
            {
                WorkingDirectory = target.WorkingDirectory
            };
            var process     = Process.Start(psi);
            var localTarget = target;

            if (process != null && debug)
            {
                process.Exited += (_, __) => localTarget.CurrentProcess = null;

                try
                {
                    var engineModes = localTarget.DebuggingEngines.Where(x => x.Selected).Select(x => x.Name).ToArray();
                    localTarget.LastError = "";
                    var result = Retrier.RunWithRetryOnException(() => Attacher.AttachVisualStudioToProcess(visualStudioProcess, process, target.UseCustomDebuggingEngines, engineModes));
                    localTarget.LastError = GetError(result);
                }
                catch (AggregateException ex)
                {
                    localTarget.LastError = ex.Message;

                    {
                        run = new RunResult
                        {
                            Message =
                                $"Errors while attaching process {target.Executable} to VS.NET. Errors : {string.Join(". ", ex.InnerExceptions.Select(e => e.Message).ToArray())}"
                        };
                        return(false);
                    }
                }
            }

            target.CurrentProcess = process;
            run = new RunResult();
            return(true);
        }