Skip to content

Commit

Permalink
Fail AppVeyor Build if MSI does not build (PowerShell#5755)
Browse files Browse the repository at this point in the history
Before this PR, when a WiX compilation error occurs then an error is thrown, which appears in the log with details but the AppVeyor build itself is still marked as green.
This PR makes the console host also return an exit code of -1 when being run on AppVeyor so that it can then interpret it as a build failure and mark the build as red. It uses the fact that AppVeyor defines an environment variable named CI. Exiting is OK since the MSI build is the last step in CI and nothing happens after that.
The git history shows a test build that proves that this works if the installer was broken.
  • Loading branch information
bergmeister authored and TravisEz13 committed Jan 2, 2018
1 parent 238ff90 commit 5f17196
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2182,7 +2182,12 @@ function New-MSIPackage
$WiXHeatLog | Out-String | Write-Verbose -Verbose
$WiXCandleLog | Out-String | Write-Verbose -Verbose
$WiXLightLog | Out-String | Write-Verbose -Verbose
throw "Failed to create $msiLocationPath"
$errorMessage = "Failed to create $msiLocationPath"
if ($null -ne $env:CI)
{
Add-AppveyorCompilationMessage $errorMessage -Category Error -FileName $MyInvocation.ScriptName -Line $MyInvocation.ScriptLineNumber
}
throw $errorMessage
}
}

Expand Down

0 comments on commit 5f17196

Please sign in to comment.