SharpeRAD / Cake.Powershell

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

Failure to log output of StartPowershellFile #18

Closed DixonDs closed 7 years ago

DixonDs commented 7 years ago

See the stacktrace:

System.FormatException: Input string was not in a correct format.
   at Cake.Diagnostics.Formatting.FormatParser.ParseProperty(TextReader reader)
   at Cake.Diagnostics.Formatting.FormatParser.<Parse>d__0.MoveNext()
   at Cake.Diagnostics.CakeBuildLog.Write(Verbosity verbosity, LogLevel level, String format, Object[] args)
   at Cake.Core.Diagnostics.LogExtensions.Debug(ICakeLog log, Verbosity verbosity, String format, Object[] args)
   at Cake.Powershell.PowershellRunner.Invoke(String script, PowershellSettings settings)
   at Submission#0.StartPowershellFile(FilePath path, PowershellSettings settings)
   at Submission#0.<.ctor>b__15()
   at Cake.Core.CakeTaskBuilderExtensions.<>c__DisplayClass5_0.<Does>b__0(ICakeContext context)
   at Cake.Core.ActionTask.Execute(ICakeContext context)
   at Cake.Core.DefaultExecutionStrategy.Execute(CakeTask task, ICakeContext context)
   at Cake.Core.CakeEngine.ExecuteTask(ICakeContext context, IExecutionStrategy strategy, Stopwatch stopWatch, CakeTask
task, CakeReport report)

It looks like to be related to this part:

if (settings.LogOutput)
{
    foreach (PSObject res in results)
    {
        _Log.Debug(Verbosity.Normal, res.ToString());
    }
}

Probably. since Cake logging supports format strings, it could be a matter of escaping of curly braces in res.ToString() before passing it to logs.

SharpeRAD commented 7 years ago

I've pushed an update that I think will solve this, if you run it again using v0.3.0

DixonDs commented 7 years ago

@SharpeRAD It solves the error, but there is some minor issue: {} from the powershell output printed as {{}}. But I guess that is something that could be fixed in core Cake only, right?