Skip to content
Kirill Osenkov edited this page Jul 30, 2025 · 20 revisions

MSBuild Structured Log Viewer now includes a graph viewer control.

Project Reference Graph

image

Target Graph

Right-click a project or evaluation and select Target Graph to view the target dependency graph for that project: image

NuGet Graph

Right-click a project or evaluation and select NuGet Graph to view the NuGet dependency graph for that project.

Right-click the NuGet node at the root level and click NuGet Graph to view the NuGet dependency graph for the entire build.

Layers by height

The vertices are organized into horizontal layers by the height of each vertex.

As an example, a project's height is defined as follows:

  • projects that don't have any references have the height of 0
  • if the maximum height of the project's reference is N, then the height of the project itself is N + 1

A project can only reference projects from the layers above it. A project can't reference projects from the same layer or from the layers beneath it.

Within a layer, projects are ordered by in-degree (number of projects that reference it) descending. Thus, more "popular" projects that are referenced more appear towards the left. The spine of the graph is along the left vertical edge (most popular projects in each layer).

Depth

A project will be a deeper shade of blue if it has larger depth. Depth is defined similarly to height, but from the opposite end. Unreferenced projects have a depth of 0, and for a referenced project the depth is one bigger than the maximum depth of all referencing projects. Projects with greater depth will also have a slightly taller rectangle.

Check the Layer by depth checkbox to order the layers by node depth. This way all unreferenced projects (depth = 0) will be in the bottom most layer.

Top to bottom, left to right

Some people have different mental models about whether more foundational layers are at the top or on the bottom. Use the Invert checkbox to flip the graph to the opposite end.

Some people may also prefer flipping the direction from vertical to horizontal, using the Horizontal checkbox.

Finding vertices

To find a vertex in a large graph by name, type the partial name into the textbox and click Locate on canvas. Once a vertex is selected, you can click Go to search to list outgoing and incoming references using the syntax described here.

Outgoing and incoming references

Clicking on a project shows all outgoing references (above) and all incoming references (below).

image

If there are too many references, check the Hide transitive references checkbox to only show the transitive reduction of the graph. It doesn't change the graph connectedness (if two vertices were connected, they will still be connected, albeit indirectly).

Connectedness and reachability

Ctrl+Click any two vertices to see whether one references the other, and if so, what are the possible paths from one to the other.

image

Dot syntax

Click on Show graph text to get the Dot syntax for the current graph:

digraph {
  "StructuredLogger.Tests" -> "StructuredLogViewer.Core"
  "StructuredLogger.Tests" -> StructuredLogger
  "StructuredLogger.Utils" -> StructuredLogger
  "StructuredLogViewer.Avalonia" -> "StructuredLogViewer.Core"
  "StructuredLogViewer.Avalonia" -> StructuredLogger
  "StructuredLogViewer.Core" -> StructuredLogger
  BinlogTool -> "StructuredLogger.Utils"
  BinlogTool -> StructuredLogger
  StructuredLogViewer -> "StructuredLogger.Utils"
  StructuredLogViewer -> "StructuredLogViewer.Core"
  StructuredLogViewer -> StructuredLogger
  StructuredLogViewer -> TaskRunner
  TaskRunner -> "StructuredLogViewer.Core"
  TaskRunner -> StructuredLogger
}

Viewing arbitrary graphs in .dot format

You can use File -> Open Graph to open arbitrary directed graph files in .dot format.

As an example, you can obtain a graph for a directory with .dll files by running the refdump .NET tool:

  • dotnet tool update -g refdump
  • refdump -g which will output the assembly dependency graph to a file in the current directory. You can then open the graph file using File -> Open Graph. It will display in a separate graph control that's not related to the build. The MSBuild Structured Log Viewer is opening directed graph files as a convenience.

See also the Dependency Analyzer tool by Drew Noakes: https://github.com/drewnoakes/dependency-analyser

Clone this wiki locally