SharpeRAD / Cake.Powershell

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

Exceptions from scripts are not being handled #60

Open stonesbg opened 6 years ago

stonesbg commented 6 years ago

I an running the below as a test to see if exception handling is working and I can't seem to get it to cause cake to exit with an exception.

Task("test123")
    .Does(() => 
    {
        StartPowershellScript("Import-Module",
            new PowershellSettings()
            {
                FormatOutput = true,
                LogOutput = true,
        ExceptionOnScriptError = true
            }.WithArguments(args =>
            {
                args.Append("ErrorAction", "Stop");
                args.Append("-Verbose");
            }));
    });

What i get in the end is the below with no failure in cake.

Import-Module : Cannot process command because of one or more missing mandatory parameters: Name.
At line:1 char:1
+ Import-Module -ErrorAction Stop -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Import-Module], ParameterBindingException
    + FullyQualifiedErrorId : MissingMandatoryParameter,Microsoft.PowerShell.Commands.ImportModuleCommand

Finished executing task: test123

The Version of cake I am using is:

Thanks for any help