SharpeRAD / Cake.Powershell

Powershell addin for Cake
http://cakebuild.net
MIT License
83 stars 36 forks source link

No error is throw when exit code is not equal to `1` #54

Open kevbite opened 6 years ago

kevbite commented 6 years ago

Not sure if this is intentional or not but I expect that running the following script would throw an exception with a none 0 exit code?

TestScript.ps1

exit 1

build.cake

Task("Default")
    .Does(() => 
    {
        StartPowershellFile("TestScript.ps1");
    });
SharpeRAD commented 6 years ago

I would be happy to change this but I'm wary that it makes assumptions about the scripts people are running. I'll leave this issue open and see if anyone chimes in on the conversation 👍

kevbite commented 6 years ago

Cool, at the moment I've worked around it with a Write-Error which then throws an exception.

Write-Error "Error Code Not Zero"
exit 1

A lot of deployment tools when running PowerShell scripts check the return code, It's why I had the assumption it should throw an exception back up and fail the build step.

I'm also happy to change the code and submit a pull request if you're happy to push in this feature?