How can I build a 'dependency tree diagram' from my .NET solution

后端 未结 5 423
忘了有多久
忘了有多久 2020-12-31 12:51

I can get easily see what projects and dlls a single project references from within a Visual Studio .NET project.

Is there any application or use of reflection that

相关标签:
5条回答
  • 2020-12-31 13:31

    NDepend comes with an interactive dependency graph coupled with a dependency matrix. You can download and use the free trial edition of NDepend for a while.

    More on NDepend Dependency Graph enter image description here

    More on NDepend Dependency Matrix: enter image description here

    Disclaimer: I am part of the tool team

    0 讨论(0)
  • 2020-12-31 13:32

    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"
    

    Sample Graph

    0 讨论(0)
  • 2020-12-31 13:38

    You can create a dependency graph of projects and assemblies in Visual Studio 2010 Ultimate by using Architecture Explorer to browse your solution, select projects and the relationships that you want to visualize, and then create a dependency graph from your selection.

    For more info, see the following topics:

    How to: Generate Graph Documents from Code: http://msdn.microsoft.com/en-us/library/dd409453%28VS.100%29.aspx#SeeSpecificSource

    How to: Find Code Using Architecture Explorer: http://msdn.microsoft.com/en-us/library/dd409431%28VS.100%29.aspx

    RC download: http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=457bab91-5eb2-4b36-b0f4-d6f34683c62a.

    Visual Studio 2010 Architectural Discovery & Modeling Tools forum: http://social.msdn.microsoft.com/Forums/en-US/vsarch/threads

    0 讨论(0)
  • 2020-12-31 13:41

    Structure101 can do that. You can browse a model by assembly and/or namespace, and clicking on any dependency at any level give you all the code-level references that cause the dependency. The .NET version is in beta, but it's been available for other languages for years, so it's very mature. Here's an example screen shot. alt text http://www.headwaysoftware.com/images/assemblies.jpg

    0 讨论(0)
  • 2020-12-31 13:48

    In addition to NDepend, you can also try this addin for Reflector for showing assembly dependency graph.

    0 讨论(0)
提交回复
热议问题