If you
ever used NuGet on a large enough solution
you know you can get into trouble when projects reference different versions of the same NuGet
package. That happens a lot in Azure projects as the libraries/packages get
updated all the time.
I'm
really surprise when I talk to people using NuGet everyday that they don't know
about the Package
Visualizer tool. (update: I've been told
that this feature requires VS Ultimate and is not available in the Pro version.
I'm still going to show it to you but stay tune for another post with a free
alternative later)
NuGet Package Visualizer in Visual Studio
Once you open
up a solution in Visual Studio you can go to the Tools
menu, NuGet Package Manager and Package Visualizer.
This will
analyse all the packages.config files in
the solution and generate a DGML
diagram of all NuGet packages and projects of the solution. The
diagram will help us see packages usage in the solution and find the ones with
different versions. Below you can see
that I've tried this on the Roslyn (open
source C# compiler) solution.
The first
thing to note (and a surprise to me!) is that Roslyn use the XUnit testing framework and not MsUnit! More seriously we can quickly see that we have no duplicate
packages with different versions. If we
compare that to this sample solution I created we can see I'm using two
versions of the Json.NET library. Now I know I should update the ClassLibrary1
project to use the new version of the package.
Of
course, this only work for NuGet packages but it would be useful to have
something like this for regular DLL references.
I'll try to work on a LinqPad query to generate such a DGML graph with
all projects, libraries and packages.
Stay tune till next time.