Cake Build Suppress MSBuild Warnings

858 Views Asked by At

I am trying to build my .net solution using cake build file. I am trying to use the documentation on the website here

My current msbuild task looks like this:

MSBuild("./solution.sln", new MSBuildSettings()
        .SetConfiguration(environmentSetting)
        .SetMSBuildPlatform(MSBuildPlatform.Automatic)
        .SetVerbosity(Verbosity.Minimal)
        .SetMaxCpuCount(System.Environment.ProcessorCount)
        .SetNodeReuse(false)
        .WithConsoleLoggerParameter("ErrorsOnly"));

It keeps throwing error for the parameter .WithConsoleLoggerParameter. I am not sure what am I doing wrong here.

The Microsoft documentation shows here the same thing and I tried running it in powershell with the same parameters and it ran just file.

1

There are 1 best solutions below

0
On

Actually I figured it out. I am not sure how the argument customization works so any explanation for that would be great!

I changed the code to

MSBuild("./solution.sln", new MSBuildSettings(){
     ArgumentCustomization = args=>args.Append("/consoleloggerparameters:ErrorsOnly") 
 }
    .SetConfiguration(environmentSetting)
    .SetMSBuildPlatform(MSBuildPlatform.Automatic)
    .SetVerbosity(Verbosity.Minimal)
    .SetMaxCpuCount(System.Environment.ProcessorCount)
    .SetNodeReuse(false));

Seems to work. Hope this helps someone!