Powershell not failing deploy

We have a console application that runs in the postdeploy.ps1 powershell script. This console application throws an exception. This exception doesn’t cause an error in the powershell script and therefore the deploy passes. Shouldn’t this fail the build? Or is there a specific way to throw an error that will cause the deploy to fail?


Throwing an error from a console application should result in a non-zero exit code being returned. You can check this exit code from PowerShell and return an error from your script. For example:

& MyApp.exe | write-host
if ($LastExitCode -ne 0) { throw 'MyApp returned a non-zero exit code...' }

Hope that helps,