If generating deps.json fails, show MSBuild output in verbose output
This commit is contained in:
parent
d471037ce3
commit
811bb94de8
2 changed files with 38 additions and 2 deletions
|
@ -376,11 +376,16 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
Path.Combine(AppContext.BaseDirectory, "MSBuild.dll") :
|
||||
msBuildExePath;
|
||||
|
||||
var result = new MSBuildForwardingAppWithoutLogging(args, msBuildExePath).Execute();
|
||||
var result = new MSBuildForwardingAppWithoutLogging(args, msBuildExePath)
|
||||
.GetProcessStartInfo()
|
||||
.ExecuteAndCaptureOutput(out string stdOut, out string stdErr);
|
||||
|
||||
if (result != 0)
|
||||
{
|
||||
// TODO: Can / should we show the MSBuild output if there is a failure?
|
||||
Reporter.Verbose.WriteLine(string.Format(
|
||||
LocalizableStrings.UnableToGenerateDepsJson,
|
||||
stdOut + Environment.NewLine + stdErr));
|
||||
|
||||
throw new GracefulException(string.Format(LocalizableStrings.UnableToGenerateDepsJson, toolDepsJsonGeneratorProject));
|
||||
}
|
||||
|
||||
|
|
|
@ -25,5 +25,36 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
|
||||
return process.ExitCode;
|
||||
}
|
||||
|
||||
public static int ExecuteAndCaptureOutput(this ProcessStartInfo startInfo, out string stdOut, out string stdErr)
|
||||
{
|
||||
var outStream = new StreamForwarder().Capture();
|
||||
var errStream = new StreamForwarder().Capture();
|
||||
|
||||
startInfo.RedirectStandardOutput = true;
|
||||
startInfo.RedirectStandardError = true;
|
||||
|
||||
var process = new Process
|
||||
{
|
||||
StartInfo = startInfo
|
||||
};
|
||||
|
||||
process.EnableRaisingEvents = true;
|
||||
|
||||
process.Start();
|
||||
|
||||
var taskOut = outStream.BeginRead(process.StandardOutput);
|
||||
var taskErr = errStream.BeginRead(process.StandardError);
|
||||
|
||||
process.WaitForExit();
|
||||
|
||||
taskOut.Wait();
|
||||
taskErr.Wait();
|
||||
|
||||
stdOut = outStream.CapturedOutput;
|
||||
stdErr = errStream.CapturedOutput;
|
||||
|
||||
return process.ExitCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue