Exemple #1
0
 private void ReportExecBegin()
 {
     if (!_quietBuildReporter)
     {
         BuildReporter.BeginSection("EXEC", FormatProcessInfo(_process.StartInfo, includeWorkingDirectory: false));
     }
 }
Exemple #2
0
 private void ReportExecBegin()
 {
     if (!_quietBuildReporter)
     {
         BuildReporter.BeginSection("EXEC", FormatProcessInfo(_process.StartInfo));
     }
 }
Exemple #3
0
 private void ReportExecWaitOnExit()
 {
     if (!_quietBuildReporter)
     {
         BuildReporter.SectionComment("EXEC", $"Waiting for process {Process.Id} to exit...");
     }
 }
Exemple #4
0
        public CommandResult Execute()
        {
            ThrowIfRunning();
            _running = true;

            if (_process.StartInfo.RedirectStandardOutput)
            {
                _process.OutputDataReceived += (sender, args) =>
                {
                    ProcessData(args.Data, _stdOutCapture, _stdOutForward, _stdOutHandler);
                };
            }

            if (_process.StartInfo.RedirectStandardError)
            {
                _process.ErrorDataReceived += (sender, args) =>
                {
                    ProcessData(args.Data, _stdErrCapture, _stdErrForward, _stdErrHandler);
                };
            }

            _process.EnableRaisingEvents = true;

            var sw = Stopwatch.StartNew();

            BuildReporter.BeginSection("EXEC", FormatProcessInfo(_process.StartInfo));

            _process.Start();

            if (_process.StartInfo.RedirectStandardOutput)
            {
                _process.BeginOutputReadLine();
            }

            if (_process.StartInfo.RedirectStandardError)
            {
                _process.BeginErrorReadLine();
            }

            _process.WaitForExit();

            var exitCode = _process.ExitCode;

            var message = $"{FormatProcessInfo(_process.StartInfo)} exited with {exitCode}";

            if (exitCode == 0)
            {
                BuildReporter.EndSection("EXEC", message.Green(), success: true);
            }
            else
            {
                BuildReporter.EndSection("EXEC", message.Red().Bold(), success: false);
            }

            return(new CommandResult(
                       _process.StartInfo,
                       exitCode,
                       _stdOutCapture?.GetStringBuilder()?.ToString(),
                       _stdErrCapture?.GetStringBuilder()?.ToString()));
        }
Exemple #5
0
        private BuildTargetResult ExecTarget(BuildTarget target)
        {
            var sectionName = $"{target.Name.PadRight(_maxTargetLen + 2).Yellow()} ({target.Source.White()})";

            BuildReporter.BeginSection("TARGET", sectionName);

            BuildTargetResult result;

            // Run the dependencies
            var dependencyResults      = new Dictionary <string, BuildTargetResult>();
            var failedDependencyResult = RunDependencies(target, dependencyResults);

            if (failedDependencyResult != null)
            {
                result = failedDependencyResult;
            }
            else if (target.Body != null)
            {
                try
                {
                    result = target.Body(new BuildTargetContext(this, target, dependencyResults));
                }
                catch (Exception ex)
                {
                    result = new BuildTargetResult(target, success: false, exception: ex);
                }
            }
            else
            {
                result = new BuildTargetResult(target, success: true);
            }
            BuildReporter.EndSection("TARGET", sectionName, result.Success);

            return(result);
        }
Exemple #6
0
        private void ReportExecEnd(int exitCode)
        {
            if (!_quietBuildReporter)
            {
                bool success = exitCode == 0;

                var message = $"{FormatProcessInfo(_process.StartInfo, includeWorkingDirectory: !success)} exited with {exitCode}";

                BuildReporter.EndSection(
                    "EXEC",
                    success ? message.Green() : message.Red().Bold(),
                    success);
            }
        }
Exemple #7
0
 private void ReportExecEnd(int exitCode)
 {
     if (!_quietBuildReporter)
     {
         var message = $"{FormatProcessInfo(_process.StartInfo)} exited with {exitCode}";
         if (exitCode == 0)
         {
             BuildReporter.EndSection("EXEC", message.Green(), success: true);
         }
         else
         {
             BuildReporter.EndSection("EXEC", message.Red().Bold(), success: false);
         }
     }
 }
Exemple #8
0
        private void ReportExecEnd(int exitCode, bool fExpectedToFail)
        {
            bool   success           = exitCode == 0;
            string msgExpectedToFail = "";

            if (fExpectedToFail)
            {
                success           = !success;
                msgExpectedToFail = "failed as expected and ";
            }

            var message = $"{FormatProcessInfo(Process.StartInfo, includeWorkingDirectory: !success)} {msgExpectedToFail}exited with {exitCode}";

            BuildReporter.EndSection(
                "EXEC",
                success ? message.Green() : message.Red().Bold(),
                success);
        }