There are two ways to use the tool: Command line or use the NuGet package in your project.
dotnet tool install --global dependency-analyzer
dependency-analyzer <SolutionFullPath> <OutputPath>
--create-graph-image: runs dot at the end of the process to create a png image of the dot graph generated. This option has a prerequisite: dot must be installed and in the PATH. To do so, you can run this command for Chocolatey:
choco install graphvizor get dot there.
This tool will create five files in the provided OutputPath:
packages.mdcontains the list of NuGet packages used by the projects in the solution, with their version.
packagesByProject.mdwill list the NuGet packages used by each project in the solution, with their version.
projectsByPackage.mddoes the opposite: it will list the projects that use each package
projectDependencyGraph.dotis the dependency graph of the projects in the solution. SolutionDependencyAnalyzer also generates a png of that graph,
Add the dependency-analyzer NuGet package to your project
DependencyAnalyzer and call it, with
Solution containing the full solution path:
var dependencyAnalyzer = new DependencyAnalyzer(Solution); await dependencyAnalyzer.AnalyzeAsync();
dependencyAnalyzer properties contain everything you need:
PackageResultscontains the package ID as key, and its version as value
ProjectResultsis a dictionary in which the key is a project, and the values are its project dependencies
PackagesByProjectis a dictionary in which the key is a project, and the values are its package dependencies
ProjectsByPackageis a dictionary in which the key is a package, and the values are its project dependencies
You can also call the writers (
DotWriter) if you want to write the same fils as the comand line tool does.