VS Solution Dependency Visualizer supports .NET Core Project Files

When I tried to analyze an unknown Visual Studio solution in my tool VS Solution Dependency Visualizer, I noticed that the project dependencies were not analyzed correctly. In fact, the dependencies were completely ignored.

A bit of research turned up that the solution in question was partly migrated to .NET Core, and the .csproj project files have a slightly different structure than good old .Net project files.

First, the classic .Net project files use a namespace

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

whereas .NET Core project files come without XML namespace, and have the root attribute Sdk:

<Project Sdk="Microsoft.NET.Sdk">

Also, files are not compiled if they are explicitly contained in the .csproj file, but rather by a rule-based Default Compilation mechanism which decides whether files in or below the project directory are compiled, embedded, or ignored.

For a detailed documentation of .NET Core project files, see MS docs or the dotnet GitHub docs.

The latest version of VS Solution Dependency Visualizer with support for .NET Core projects is available for download here.

BTW: In previous versions of this tool, I tried to register VS Solution Dependency Visualizer as an External Tool in all installed versions of Visual Studio.

However, things change all the time, and VS 2013 was the first version that did not support registration via registry, and with VS 2017 things got even more different, and finally I had to give up.

Instructions on how to add VS Solution Dependency Visualizer as an External Tool in your version of Visual Studio can be found in the readme file that comes with the installer.

Assembly References in VS Solution Dependency Visualizer 0.93

One thing that always bugged (haha) me with VS Solution Dependency Visualizer was that it did not distinguish between different referenced assemblies in different locations.

For example, if a VS solution contains one C# project P1 that references a project “MyTools” (also part of that solution), but project P2 references an assembly “MyTools” (e.g. as binary, or as the output of said project), then VS Solution Dependency Visualizer would not distinguish these assemblies, and extract incorrect dependency information from the solution and its projects.

Well, this has now been fixed.

Version 0.93 will now distinguish assemblies, whether they are in the solution, in the file system, or in the GAC.

As a consequence, it is now possible to analyze the solution for

  • assemblies missing in the file system or in the GAC
  • duplicate assemblies (same name, different location)

and to list all assemblies referenced by the solution.

To check for GAC assemblies, it was necessary to create a .Net 4 build as well, as assemblies can only be loaded if their .Net version is lower or equal to the .Net version of the executable that loads them.

A minor UI fix, the solution folders and projects are now sorted alphabetically in the solution tree.

As usual, the latest release of VS Solution Dependency Viewer is available for download here.

List Invalid Guids of Referenced Projects in VS Solution Dependency Visualizer 0.92

While preparing one of my projects for production, I came across a “funny” error:

While Visual Studio builds a solution without errors, msbuild raised the following error for an ASP.Net web application:

The type or namespace name ‘foo.bar’ does not exist in the namespace ‘foo’ (are you missing an assembly reference?)

I checked in Solution Explorer, and the project reference was clearly there, the assembly showed the namespace in ILSpy, and VS built the solution.

A little panicky, I removed the project reference and added it again. msbuild was now able to build the web application, but the build process raised solution file warnings:

c:\path\to\solution.sln : Solution file warning MSB4051: Project {Some-GUID-0001} is referencing a project with GUID {Other-GUID-0002}, but a project with this GUID was not found in the .SLN file.

Notice that the error message does NOT inform us while project contains the reference, and which other project was meant to be referenced, even though VS has all the necessary information to display the projects.

So I started another instance of VS, opened the VSSlnDep project, and added a new function, “List Invalid Guids of Project References”.

This function iterates through the project references of each project file (*.csproj, *.vbproj), and checks whether the referenced Guid is the project Guid of any project in the solution. If not, the reference is displayed using the referring and the referred project file names, along with both Guids.

To solve the invalid Guids, you need to navigate to the referring project in Solution Explorer, delete the project reference and add it again.

Conclusion 1: Visual Studio seems to resolve references using the project file name, whereas msbuild resolves using the project Guids.

Conclusion 2: Nobody knows why VS changes project Guids. Not even Microsoft.

As usual, the latest release of VS Solution Dependency Viewer is available for download here.

List Shared Project Files in VS Solution Dependency Visualizer 0.91

A user of VS Solution Dependency Visualizer inherited a couple of copy-and-paste projects and asked whether it was possible to detect which files and directories are used by which projects.

As for directories, if you check the “Include Files” options, click “Analyze”, and switch to the “Analysis” tab, and invoke “List Directories” or “List Project Directories”,  VS Solution Dependency Visualizer displays all directories used by files in any project of the opened solution, either for the whole solution, or per project.

The updated version 0.91 also implements the options “List Files” and “List Project Files”, again displaying the list of files in the whole solution, or per project. (This List Files function was implemented in earlier versions as part of the display of a solution or project node in the tree view, but removed in the meantime)

I also added an analysis function “List Shared Project Files” which displays all files that are part of at least 2 projects in a solution (i.e. files that have been added using the “Add As Link” button).

In the tree view display of the Analysis tab, the names of the shared (or linked) files are displayed as root nodes, and the projects that contain them as child nodes.

As usual, the latest release of VS Solution Dependency Viewer is available for download here.

Support for VB.Net in VS Solution Dependency Visualizer 0.90

VS Solution Dependency Visualizer user janv8000 asked whether it would be possible to add analysis of VB.Net projects to vssdv. Until version 0.80, only C# projects were supported.

I had a look through the source code and was surprised that there were only a couple of places that caused the restriction to C#. After modifying teh codez to include VB.Net projects, I just needed a real-world VB.Net to test the new functionality. I knew that DNN changed from VB to C# in version 6, so I downloaded the source code of version 4 and 5 to run my tests.

See the results here.

Resulting png’s show the dependency analysis of the DNN solutions from version 4 thru version 6, both with dependencies between source code projects, and dependencies on referenced project assemblies (without GAC assemblies).

Another issue that bugged me for quite some time now was the poor performance during dependency analysis. The root of the bug lay in a Linq statement which effectively caused a nested loop, and was resolved by replacing a .Where() condition by a Dictionary of respective types.

As usual, the latest release of VS Solution Dependency Viewer is available for download here.

VS Solution Dependency Visualizer maintenance release 0.80

The new version 0.80 of VS Solution Dependency Visualizer adds one more analysis function: extract all [assembly: ] attributes and values from C# files in all solution projects.

It also fixes a bug that may occur during the analysis of some .csproj project files.

As usual, the latest release of VS Solution Dependency Viewer is available for download here.

Analyzing Visual Studio Solutions

VS Solution Dependency Visualizer was originally started as a tool to generate dependency charts of projects and assemblies contained in a Visual Studio Solution (.sln) file.

As the program evolved, textual analysis features have been included: display lists of referencing and referenced projects and assemblies, list containing directories, etc.

The new version 0.70 of VS Solution Dependency Visualizer adds more analysis functions:

List Project Properties

displays Output Type, Assembly Name, Root Namespace, and Framework Version

List Namespaces


analyzes C# projects for namespace declarations

List Web URLs

extracts the URLs of Web Application projects

List Web Service URLs

extracts URLs of .asmx files and web service declarations from app.config.

Dependency Chart

The application’s user interface has been re-worked so that the dependency chart is now contained in a tab of the (single) main window.

Project Coupling

displays coupling metrics indicating stability and responsibility of included projects.

More screenshots can be viewed in the gallery. As usual, the latest release of VS Solution Dependency Viewer is available for download here.