nuke icon indicating copy to clipboard operation
nuke copied to clipboard

Add support for FileLogger and FileLoggerParameters in MSBuildSettings.

Open alphaleonis opened this issue 5 years ago • 3 comments

MSBuild supports the parameters -fileLogger and -fileLoggerParameters to enable additional logging to a file. Would be nice to have these easily accessible in the MSBuildSettings.

A suggested interface would be something like the following:

MSBuild(s => s
   .SetTargetPath(Solution)
   .SetTargets("Build")
   .SetFileLogger(f => f
      .SetLogFile("MyLogFile.log")
      .SetVerbosity(MSBuildVerbosity.Diagnostic)
      .EnableShowTimestamp()
      .EnableAppend()
   )
   .SetNodeReuse(IsLocalBuild));

This should result in the command line:

msbuild.exe <solution> /t:Build /fl /flp:"LogFile=MyLogFile.log;Verbosity=Diagnostic;Append;ShowTimestamp"

alphaleonis avatar Sep 22 '19 17:09 alphaleonis

I currently don't see a way to autogenerate code for this type of parameter specification. It is quite specialized. I would be happy to manually implement this and submit a PR if that would be an admissible solution.

alphaleonis avatar Sep 22 '19 17:09 alphaleonis

MSBuild.json would require additional dataclasses, depending on the amount of logger types. Also I suggest to extend code generation to allow some sort of callback, that gets implemented manually (for now) in another partial file. Convenience methods like ClearLoggers should be guaranteed.

matkoch avatar Sep 22 '19 18:09 matkoch

Took a brief initial look at this, and it seems quite doable using the dataClasses and a customValue implementation for the actual parameter that is manually implemented. Don't see the need for an additional callback method at this point, but perhaps I'm missing something?

I'm planning to take a stab at it and submit a PR when done though.

alphaleonis avatar Sep 24 '19 18:09 alphaleonis

Binary log files exist meanwhile.

matkoch avatar Nov 29 '22 04:11 matkoch