private void DumpMSBuildOutput(OutputCapture capture) { _reporter.Output($"MSBuild output from target '{TargetName}':"); _reporter.Output(string.Empty); foreach (var line in capture.Lines) { _reporter.Output($" {line}"); } _reporter.Output(string.Empty); }
public async Task <string> ExecuteAsync(string buildConfiguration, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var projectDir = Path.GetDirectoryName(_projectFile); OutputCapture capture = _outputSink.StartCapture(); IEnumerable <string> args = new[] { "msbuild", _projectFile, } .Concat(BuildFlags); if (buildConfiguration != null) { args = args.Append($"/p:Configuration=\"{buildConfiguration}\""); } var processSpec = new ProcessSpec { Executable = DotNetMuxer.MuxerPathOrDefault(), WorkingDirectory = projectDir, Arguments = args, OutputCapture = capture }; _reporter.Verbose($"Running MSBuild target '{TargetName}' on '{_projectFile}'"); var exitCode = await _processRunner.RunAsync(processSpec, cancellationToken); if (exitCode != 0) { _reporter.Error($"Failed to build the project file '{Path.GetFileName(_projectFile)}'"); DumpMSBuildOutput(capture); return(null); } Match targetPathMatch = capture.Lines .Select(line => Regex.Match(line, @"Bundling\.TargetPath=<(.+)>")) .FirstOrDefault(match => match.Success); if (targetPathMatch == null) { _reporter.Error("Failed to determine the path of the output assembly."); DumpMSBuildOutput(capture); return(null); } return(targetPathMatch.Groups[1].Value); }