We use PowerShell for some of our automated build scripts. Unfortunately, by default, PowerShell continues after an error.
Ordinarily, I can change this behaviour by setting $ErrorActionPreference = Stop.
I can't see a corresponding command line switch for PowerShell.exe, and we (deliberately) run the commands with -noprofile, so I can't put it in there.
How do I do this for a build script?
Put it at the top of the script you're running?
$ErrorActionPreference = 'Stop'
Alternatively, you can also get similar control at the cmdlet level using the ErrorAction parameter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With