SharpeRAD / Cake.Powershell

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

Adding .SetFormatOutput() to Settings will break any return codes from called script. #29

Closed deekob closed 7 years ago

deekob commented 7 years ago

There seems to have been a regression - as the Task("Failing-Powershell-File") example in the test package does not work as expected. The Test is this `Task("Failing-Powershell-File") .Description("An example showing how to handle errors from Powershell scripts") .Does(() => { Information("Calling failing Powershell File");

    var resultCollection = StartPowershellFile("./failingScript.ps1", new PowershellSettings()
        **.SetFormatOutput()**
        .SetLogOutput());

    var returnCode = int.Parse(resultCollection[0].BaseObject.ToString());
    if (returnCode != 0) {
        throw new ApplicationException("Script failed to execute");
    }
});`

This will now not work as expected until you remove the .SetFormatOutput() PowerShellSetting. This is consistent to what we have been experiencing.

Also of note is that the Task above is not actually wired into anything and will only run as a custom target - I dont think that is expected.

SharpeRAD commented 7 years ago

Hopefully this is clearer?