PowerShell scripts best-practice

Matt Houser's Avatar

Matt Houser

15 Nov, 2018 04:06 PM

I am switching my build from non-appveyor.yml + cmd to appveyor.yml + powershell.

Previously, when a command-line program failed, the whole build stopped.
But now, using PowerShell, I'm finding that Powershell seems to "eat" the failures and not pass them on to AppVeyor. So AppVeyor reports build success, even though a command-line tool failed.

What is the best way to (a) format powershell scripts that execute command-line programs, and (b) call those ps1 scripts from AppVeyor so that failed builds are reported properly?

  1. Support Staff 1 Posted by Owen McDonnell on 15 Nov, 2018 07:22 PM

    Owen McDonnell's Avatar

    In answer to the first question (a), it depends on what you are calling. If it is in the environment path variable, you should be able to call it directly, if not, you may need to use the call operator (&) to access the directory. Here is a useful summary.

    For the second question, the $ErrorActionPreference variable is set to continue by default, but you can set it to $ErrorActionPreference = Stop at the beginning of a script.

  2. Ilya Finkelshteyn closed this discussion on 15 Jan, 2019 09:00 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

 

21 Mar, 2019 05:38 PM
21 Mar, 2019 06:16 AM
21 Mar, 2019 01:47 AM
20 Mar, 2019 11:39 PM
20 Mar, 2019 09:03 PM
20 Mar, 2019 08:55 PM