MSBuild Visualizer

I’ve been spending a bit of time spelunking around MSBuild internals, and as part of the process I’ve needed to build up a little bit of a mental map of the built-in targets and their dependencies. As a bit of an excercise I decided I would load up a project file using the object model in the Microsoft.Build.BuildEngine namespace and then render the relationships between the targets. Here was the output of my first attempt.


Admittedly its not the most readable diagram, and about the only thing you can really appreciate from it is that its C-O-M-P-L-E-X. Notice the smudge on the top left hand corner? Thats the text of the overlapping rectangles that I couldn’t be bothered dragging out manually.

I actually whipped this up in about fifteen minutes and leveraged the Netron library to do the graphical work. Its actually pretty neat, but because I used the Netron Light version it doesn’t include things like automatic layout etc. I’m not real proud of the code (don’t judge me by it), but it is functional if a little ugly. The whole excercise did leave me with a couple of questions though:

  • What is the easiest way to expand properties programatically? My reflection-code ain’t it.
  • Why aren’t Project.DefaultTargets and Target.DependsOnTargets exposed as a TargetCollection instead of a string? I suspect it might have something to do with property expansion.
  • What is another question I could ask here?

4 thoughts on “MSBuild Visualizer

  1. David Smith

    Not Bad!

    Using directed arrows for the links, and a more intuitive display would be very cool. Especially for a teaching class, to say: “look, this is what happens!”

    And Netron looks like fun, thanks for the reference.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s