ProcessWrapper StartProcess(string command, string arguments, string workingDirectory, TextWriter outWriter, TextWriter errorWriter, EventHandler exited)
        {
            int currentSessionId = Interlocked.Increment(ref sessionId);

            var msbuildProcessArguments = new MSBuildProcessArguments(arguments);

            var buildTarget = new MSBuildTarget {
                ProjectName     = GettextCatalog.GetString("Solution"),
                ProjectFileName = GettextCatalog.GetString("Solution"),
                Targets         = msbuildProcessArguments.Targets,
                BuildType       = msbuildProcessArguments.BuildType,
                Dimensions      = GetDimensions(msbuildProcessArguments.Targets)
            };

            buildTarget.Start();

            arguments = MSBuildProcessArguments.AddVerbosity(arguments, Runtime.Preferences.MSBuildVerbosity.Value);
            arguments = MSBuildProcessArguments.AddBinLogFileName(arguments, buildTarget.BinLogFileName);

            lock (buildTargets) {
                buildTargets [currentSessionId] = buildTarget;
            }

            ProjectSystemService.OnTargetStarted(buildTarget);

            var monitor = new MSBuildProcessProgressMonitor(outWriter, errorWriter, buildTarget.LogFileName);

            ProcessWrapper process = Runtime.ProcessService.StartProcess(
                command,
                arguments,
                workingDirectory,
                monitor.Log,
                monitor.ErrorLog,
                exited);

            monitor.Process = process;

            process.Task.ContinueWith(_ => {
                OnMSBuildProcessExited(currentSessionId, monitor);
            });

            return(process);
        }
        public MSBuildTargetMonitor(
            Project project,
            string target,
            ConfigurationSelector configuration,
            TargetEvaluationContext context)
        {
            // Ensure log verbosity is set for non-build targets.
            this.context         = context;
            context.LogVerbosity = Runtime.Preferences.MSBuildVerbosity.Value;

            buildTarget = new MSBuildTarget {
                ProjectName     = project.Name,
                ProjectFileName = project.FileName,
                Targets         = target ?? string.Empty,
                BuildType       = MSBuildTarget.GetBuildType(target),
                Dimensions      = project.GetDimensions(configuration)
            };

            buildTarget.Start();

            ProjectSystemService.OnTargetStarted(buildTarget);
        }