From 5f171963b5dfdb5f205a4bb2ffe5a616fc02f6cf Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 2 Jan 2018 23:08:32 +0000 Subject: [PATCH] Fail AppVeyor Build if MSI does not build (#5755) 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. --- build.psm1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build.psm1 b/build.psm1 index 06e34e0b3..e6c37c531 100644 --- a/build.psm1 +++ b/build.psm1 @@ -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 } }