SharpeRAD / Cake.Powershell

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

StartPowershellFile result 0 but doesn't take any effect #78

Open Geolle opened 4 years ago

Geolle commented 4 years ago

I wrote this in my cake script

        var collection= StartPowershellFile("C:\\Project\\Spacebuilder\\greenblue.ps1", new PowershellSettings()
        {
            ComputerName = config.Server.ServerName,
            Username = config.Server.UserName,
            Password = config.Server.Password,
            FormatOutput = true,
            LogOutput = true
        }); 

        foreach (var item in collection)
        {
            Information("Result: {0}", item.BaseObject.ToString());
        }

It returns Result: 0 but there is no output. if I use scripts below

    StartPowershellScript("echo \"111\"", new PowershellSettings()
        {
            ComputerName = config.Server.ServerName,
            Username = config.Server.UserName,
            Password = config.Server.Password,

            FormatOutput = true,
            LogOutput = true
        });

it is ok and returns 111 or if I read the greenblue.ps1 into a string and execute through StartPowershellScript it also works Why?

Geolle commented 4 years ago

This is the output from cake

Executing: echo "111"
111
Executing: &"C:/Project/Spacebuilder/greenblue.ps1"
Result: 0