KirillOsenkov / MSBuildStructuredLog

A logger for MSBuild that records a structured representation of executed targets, tasks, property and item values.
MIT License
1.44k stars 191 forks source link

Consider allowing to split out a subtree of a binlog into a smaller binlog #157

Open KirillOsenkov opened 6 years ago

KirillOsenkov commented 6 years ago

If the master build is building multiple solutions via MSBuild task, consider allowing to split out separate binlogs for each MSBuild invocation.

Does MSBuild task support an equivalent of /bl?

Would be nice to right-click a node in the tree and say "Save subtree as a separate log"

japj commented 6 years ago

I just realised that apart from splitting at build time, it might also be (more?) feasible to do the splitting post build? That might depend on the availability of a binlog API parsing/writing library?

KirillOsenkov commented 6 years ago

That should be easy. There is already an API to read all the records from a .binlog: StructuredLogger.dll from https://www.nuget.org/packages/Microsoft.Build.Logging.StructuredLogger

https://github.com/KirillOsenkov/MSBuildStructuredLog/blob/master/src/StructuredLogger/BinaryLogger/BinaryLogReplayEventSource.cs#L84

You can replay the .binlog into another logger, and filter to just the records that you care about (perhaps by some field on BuildEventArgs.BuildEventContext?)

Also there are various ways to convert a .binlog to a .buildlog (basically what the Structured Log Viewer does to display the tree). Once you have a .buildlog you can easily save a subtree into binary or XML format. It's all very flexible, let me know if you get stuck with any of it.