private async Task ExecuteBuild() { _chalk.Default("Building Test Project..."); var log = new StringBuilder(); void OutputData(object sender, string args) => log.AppendLine(args); var testCodeBuild = new BuildExecutor(MuTestSettings, _options.TestProjectParameter) { BaseAddress = MuTestSettings.ServiceAddress, EnableLogging = _options.EnableDiagnostics, QuietWithSymbols = true }; testCodeBuild.OutputDataReceived += OutputData; testCodeBuild.BeforeMsBuildExecuted += (sender, args) => { _chalk.Yellow($"\nRunning MSBuild with {args}\n"); }; if (_options.BuildInReleaseModeParameter) { if (_options.OptimizeTestProject) { await testCodeBuild.ExecuteBuildInReleaseModeWithoutDependencies(); } else { await testCodeBuild.ExecuteBuildInReleaseModeWithDependencies(); } } else { if (_options.OptimizeTestProject) { await testCodeBuild.ExecuteBuildInDebugModeWithoutDependencies(); } else { await testCodeBuild.ExecuteBuildInDebugModeWithDependencies(); } } testCodeBuild.OutputDataReceived -= OutputData; if (testCodeBuild.LastBuildStatus == BuildExecutionStatus.Failed) { throw new MuTestFailingBuildException(log.ToString()); } _chalk.Green("\nBuild Succeeded!\n"); }
private async Task <bool> ExecuteBuild() { try { var buildLog = _outputLogger.GetLogFromOutput(MSBuildOutput, string.Empty); var document = MutationDocumentManagerService.CreateDocument(nameof(CommandPromptOutputViewer), buildLog); document.Title = MSBuildOutput; document.Show(); buildLog.CommandPromptOutput += "Building Test Project...".PrintWithPreTag(); void OutputData(object sender, string args) => buildLog.CommandPromptOutput += args.Encode().PrintWithPreTag(); var testCodeBuild = new BuildExecutor(Settings, _source.TestClaz.ClassProject) { BaseAddress = Settings.ServiceAddress, EnableLogging = ChkEnableDiagnostic.IsChecked, QuietWithSymbols = true }; testCodeBuild.OutputDataReceived += OutputData; if (_source.BuildInReleaseMode) { await testCodeBuild.ExecuteBuildInReleaseModeWithoutDependencies(); } else { await testCodeBuild.ExecuteBuildInDebugModeWithoutDependencies(); } testCodeBuild.OutputDataReceived -= OutputData; if (testCodeBuild.LastBuildStatus != BuildExecutionStatus.Failed) { document.Close(); } else { MessageBoxService.Show("\nTest Project Build is failed!"); } return(testCodeBuild.LastBuildStatus == BuildExecutionStatus.Success); } catch (Exception e) { MessageBoxService.Show(e.Message); Trace.TraceError("Unknown Exception Occurred On Test Project Build {0}", e); return(false); } }