SharpeRAD / Cake.Powershell

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

Errors thrown in scripts are not shown and not failing the build. #24

Closed DixonDs closed 7 years ago

DixonDs commented 7 years ago

Error.ps1:

throw "My error";

build.cake:

#addin "Cake.Powershell"

var target = Argument("target", "Default");

Task("Default")
    .Does(() =>
{
    StartPowershellFile("error.ps1");
});

RunTarget(target);

When you run "error.ps1" directly, it outputs the error to the powershell console. But if you run standard "build.ps1" invoking "build.cake" above, it doesn't output any error and shows the build as successful.

matkoch commented 7 years ago

As far as I've noticed, the exit code is the first element contained in the returned collection.

@SharpeRAD is there any reasoning behind that?

SharpeRAD commented 7 years ago

This should probably be changed, it was introduced in #23. A more consistent approach would be to not output the exist code and throw errors.

Happy to accept a PR for the change as there are more than enough votes for it 👍

yanigisawa commented 7 years ago

I'm running into the same behavior, I'm taking a look at this issue.

SharpeRAD commented 7 years ago

Fixed in v0.3.5 courtesy of @yanigisawa 👍