Browse Source

Log from stdout when dotnet publish fails (#456)

davidfowl/ingress-changes
Justin Kotalik 6 years ago
committed by GitHub
parent
commit
c7a2b30462
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 24
      src/Microsoft.Tye.Core/PublishProjectStep.cs

24
src/Microsoft.Tye.Core/PublishProjectStep.cs

@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license. // The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.
using System;
using System.CommandLine.Invocation; using System.CommandLine.Invocation;
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -36,18 +37,29 @@ namespace Microsoft.Tye
output.WriteDebugLine("Running 'dotnet publish'."); output.WriteDebugLine("Running 'dotnet publish'.");
output.WriteCommandLine("dotnet", $"publish \"{project.ProjectFile.FullName}\" -c Release -o \"{outputDirectory.DirectoryPath}\""); output.WriteCommandLine("dotnet", $"publish \"{project.ProjectFile.FullName}\" -c Release -o \"{outputDirectory.DirectoryPath}\"");
var capture = output.Capture();
var exitCode = await Process.ExecuteAsync( var publishResult = await ProcessUtil.RunAsync(
$"dotnet", $"dotnet",
$"publish \"{project.ProjectFile.FullName}\" -c Release -o \"{outputDirectory.DirectoryPath}\"", $"publish \"{project.ProjectFile.FullName}\" -c Release -o \"{outputDirectory.DirectoryPath}\"",
project.ProjectFile.DirectoryName, project.ProjectFile.DirectoryName,
stdOut: capture.StdOut, throwOnError: false);
stdErr: capture.StdErr);
output.WriteDebugLine($"Done running 'dotnet publish' exit code: {exitCode}"); output.WriteDebugLine($"Done running 'dotnet publish' exit code: {publishResult.ExitCode}");
if (exitCode != 0) if (publishResult.ExitCode != 0)
{ {
outputDirectory.Dispose(); outputDirectory.Dispose();
output.WriteInfoLine($"'dotnet publish' failed. Error:");
foreach (var line in publishResult.StandardOutput.Split(Environment.NewLine))
{
output.WriteInfoLine(line);
}
foreach (var line in publishResult.StandardError.Split(Environment.NewLine))
{
output.WriteInfoLine(line);
}
throw new CommandException("'dotnet publish' failed."); throw new CommandException("'dotnet publish' failed.");
} }

Loading…
Cancel
Save