Search code examples
logging.net-corecakebuild

Log the warning messages into a text file from a cake script for DotNetCoreBuild


Is it possible to do the same thing as here but for DotNetCoreBuild? If yes, how?

This workaround is not suitable, because I need to execute a next target and I need those logs after build step.


Solution

  • var target = Argument("target", "Build");
    
    var slnPath = "./src/some-project.sln";
    var distDirectory = Directory("./dist");
    
    Task("Build")
        .Does(() =>
        {
            var settings = new DotNetCoreMSBuildSettings();
            settings.FileLoggers.Add(new MSBuildFileLoggerSettings(){
                LogFile = "./WarningReportes.txt",
                SummaryOutputLevel = MSBuildLoggerOutputLevel.WarningsOnly
            });
            DotNetCoreMSBuild(slnPath, settings);
        });
    
    
    RunTarget(target);