From 5ce20ebdde720c1f68371bcd9f6a1abe405dde7c Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Sun, 16 Jun 2019 21:51:48 -0700 Subject: [PATCH] Do not exit cleanly after failed `msbuild` in `build.ps1`'s `finally` block - part of aspnet/AspNetCore-Internal#2665 - should surface errors we're currently hiding Also increase PowerShell logging to help debug build and test hangs nit: Run `finally` block after catching an exception --- build.ps1 | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/build.ps1 b/build.ps1 index daa376269f..018c3970b7 100644 --- a/build.ps1 +++ b/build.ps1 @@ -324,6 +324,7 @@ if ($tmpBinaryLog) { # Capture MSBuild crash logs $env:MSBUILDDEBUGPATH = $LogDir +$local:exit_code = $null try { # Import custom tools configuration, if present in the repo. # Note: Import in global scope so that the script set top-level variables without qualification. @@ -342,6 +343,10 @@ try { $restore = $tmpRestore + if ($ci) { + $global:VerbosePreference = 'Continue' + } + if (-not $NoBuildRepoTasks) { MSBuild $toolsetBuildProj ` /p:RepoRoot=$RepoRoot ` @@ -359,9 +364,13 @@ try { catch { Write-Host $_.ScriptStackTrace Write-PipelineTaskError -Message $_ - ExitWithExitCode 1 + $exit_code = 1 } finally { + if (! $exit_code) { + $exit_code = $LASTEXITCODE + } + # tools.ps1 corrupts global state, so reset these values so they don't carry between invocations of build.ps1 rm variable:global:_BuildTool -ea Ignore rm variable:global:_DotNetInstallDir -ea Ignore @@ -378,4 +387,4 @@ finally { } } -ExitWithExitCode 0 +ExitWithExitCode $exit_code