.net-core.net-core-2.0

dotnet build with logger


If I want to specify a logger where I can set the name and location of the log file, I do the following:

dotnet build /l:FileLogger,Microsoft.Build.Engine;logfile=MyLog.log

This syntax has worjked for me in the past with msbuild, however it is not working with dotnet. What am I doing wrong?

enter image description here


Solution

  • I took me some time to find this, but you can use fileloggerparameters (flp)

    dotnet build /flp:v=diag
    

    This will create log file msbuild.log. The Option [v]erbosity is set to [diag]nostic. But you can choose others verbosity levels.

    Use the option logfile to specify the name of the log file.

    dotnet build /flp:v=diag;logfile=MyLog.log
    

    This also works with msbuild

    msbuild /flp:v=diag;logfile=MyLog.log
    

    Using Powershell the command for dotnet looks like

    dotnet build /flp:v=diag /flp:logfile=MyLog.log