A dependency graph is a data structure formed by a directed graph that describes the dependency of an entity in the system on the other entities of the same system. The underlying structure of a dependency graph is a directed graph where each node points to the node on which it depends.
I needed something similar, but didn't want to pay for (or install) a tool to do it. I created a quick PowerShell script that goes through the project references and spits them out in a yuml.me friendly-format instead:
Function Get-ProjectReferences ($rootFolder)
{
$projectFiles = Get-ChildItem $rootFolder -Filter *.csproj -Recurse
$ns = @{ defaultNamespace = "http://schemas.microsoft.com/developer/msbuild/2003" }
$projectFiles | ForEach-Object {
$projectFile = $_ | Select-Object -ExpandProperty FullName
$projectName = $_ | Select-Object -ExpandProperty BaseName
$projectXml = [xml](Get-Content $projectFile)
$projectReferences = $projectXml | Select-Xml '//defaultNamespace:ProjectReference/defaultNamespace:Name' -Namespace $ns | Select-Object -ExpandProperty Node | Select-Object -ExpandProperty "#text"
$projectReferences | ForEach-Object {
"[" + $projectName + "] -> [" + $_ + "]"
}
}
}
Get-ProjectReferences "C:\Users\DanTup\Documents\MyProject" | Out-File "C:\Users\DanTup\Documents\MyProject\References.txt"
Update: ReSharper since version 8 has built-in 'View Project Dependencies' feature.
ReSharper version prior to 8 has Internal feature to show dependency graphs in using yFiles viewer. See quick manual in the bottom of the post.
Howto
Have you tried NDepend? It'll shows you the dependencies and you can also analyze the usability of your classes and methods.
Their website:
http://ndepend.com
To complete the @Eriawan answer in April 2020 NDepend version 2020.1 has been released with Dependency Graph completely rebuilt. It now scales on large solutions made of hundreds of projects and offers many navigation facilities.
Here is what it looks like on the NopCommerce OSS project.
Here is what it looks like on the entire .NET Core 3 classes library (176 assemblies).
Disclaimer: I work at NDepend
You can get a project dependency graph easily using Visual Studio 2010 Ultimate, scan to 5 minutes into this video to see how: http://www.lovettsoftware.com/blogengine.net/post/2010/05/27/Architecture-Explorer.aspx
In Visual Studio 2010 Ultimate: Architecture | Generate Dependency Graph | By Assembly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With