diff --git a/eng/common/Invoke-ImageBuilder.ps1 b/eng/common/Invoke-ImageBuilder.ps1 index 93a0fe52cb..3ba85786bb 100644 --- a/eng/common/Invoke-ImageBuilder.ps1 +++ b/eng/common/Invoke-ImageBuilder.ps1 @@ -48,6 +48,8 @@ function Exec { Log "Executing: '$Cmd'" Invoke-Expression $Cmd if ($LASTEXITCODE -ne 0) { + $host.SetShouldExit($LASTEXITCODE) + exit $LASTEXITCODE throw "Failed: '$Cmd'" } }