Skip to content

Commit

Permalink
[Xamarin.ProjectTools] log ExitCode when MSBuild exits (dotnet#5406)
Browse files Browse the repository at this point in the history
Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=4291650&view=ms.vss-test-web.build-test-results-tab&runId=17600706&resultId=100198&paneView=attachments

We have occasionally seen failures under `dotnet build` such as:

    Project should have built.
    Expected: True
    But was:  False

But then the diagnostic MSBuild log says:

    Build succeeded.
        0 Warning(s)
        0 Error(s)

Looking at the logic in `Builder.BuildInternal()`, it seems like this
means the `ExitCode` was non-zero. There was no `Build Timed Out!` log
message either.

We should log the exit code, which might help diagnose the issue.
  • Loading branch information
jonathanpeppers authored Dec 14, 2020
1 parent 59b18d0 commit 97bbdd4
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,17 @@ protected bool BuildInternal (string projectOrSolution, string target, string []
if (psi.RedirectStandardError)
err.WaitOne ();
result = ranToCompletion && p.ExitCode == 0;
if (processLog != null) {
if (ranToCompletion) {
File.AppendAllText (processLog, $"ExitCode: {p.ExitCode}{Environment.NewLine}");
} else {
File.AppendAllText (processLog, $"Build Timed Out!{Environment.ExitCode}");
}
}
}

LastBuildTime = DateTime.UtcNow - start;

if (processLog != null && !ranToCompletion)
File.AppendAllText (processLog, "Build Timed Out!");
if (buildLogFullPath != null && File.Exists (buildLogFullPath)) {
foreach (var line in LastBuildOutput) {
if (line.StartsWith ("Time Elapsed", StringComparison.OrdinalIgnoreCase)) {
Expand Down

0 comments on commit 97bbdd4

Please sign in to comment.