Skip to content

Commit 5ce20eb

Browse files
committed
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
1 parent 495f529 commit 5ce20eb

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

build.ps1

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ if ($tmpBinaryLog) {
324324
# Capture MSBuild crash logs
325325
$env:MSBUILDDEBUGPATH = $LogDir
326326

327+
$local:exit_code = $null
327328
try {
328329
# Import custom tools configuration, if present in the repo.
329330
# Note: Import in global scope so that the script set top-level variables without qualification.
@@ -342,6 +343,10 @@ try {
342343

343344
$restore = $tmpRestore
344345

346+
if ($ci) {
347+
$global:VerbosePreference = 'Continue'
348+
}
349+
345350
if (-not $NoBuildRepoTasks) {
346351
MSBuild $toolsetBuildProj `
347352
/p:RepoRoot=$RepoRoot `
@@ -359,9 +364,13 @@ try {
359364
catch {
360365
Write-Host $_.ScriptStackTrace
361366
Write-PipelineTaskError -Message $_
362-
ExitWithExitCode 1
367+
$exit_code = 1
363368
}
364369
finally {
370+
if (! $exit_code) {
371+
$exit_code = $LASTEXITCODE
372+
}
373+
365374
# tools.ps1 corrupts global state, so reset these values so they don't carry between invocations of build.ps1
366375
rm variable:global:_BuildTool -ea Ignore
367376
rm variable:global:_DotNetInstallDir -ea Ignore
@@ -378,4 +387,4 @@ finally {
378387
}
379388
}
380389

381-
ExitWithExitCode 0
390+
ExitWithExitCode $exit_code

0 commit comments

Comments
 (0)