Dependency graph of Visual Studio projects

前端 未结 16 2281
鱼传尺愫
鱼传尺愫 2020-11-28 17:42

I\'m currently migrating a big solution (~70 projects) from VS 2005 + .NET 2.0 to VS 2008 + .NET 3.5. Currently I have VS 2008 + .NET 2.0.

The problem is that I need

相关标签:
16条回答
  • 2020-11-28 18:08

    Update: ReSharper since version 8 has built-in 'View Project Dependencies' feature.

    ReSharper version < 8 has Internal feature to show dependency graphs in using yFiles viewer. See quick manual in the bottom of the post.

    enter image description here

    Howto

    1. Install yEd tool from here.
    2. Run VS with /resharper.internal command line argument.
    3. Go to ReSharper/Internal/Show Dependencies.
    4. Specify projects that you want to include to the 'big picture'.
    5. Uncheck 'Exclude terminal nodes...' unless you need it.
    6. Press 'Show'.
    7. Use hierarchical layout in yEd (Alt+Shift+H)
    8. Provide feedback =)
    0 讨论(0)
  • 2020-11-28 18:08

    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.

    0 讨论(0)
  • 2020-11-28 18:13

    VS 2019 has renamed dependency graph module to Code Map

    here is official documentation : https://docs.microsoft.com/en-us/visualstudio/modeling/map-dependencies-across-your-solutions?view=vs-2019

    0 讨论(0)
  • 2020-11-28 18:13

    This extended version of the PS Script from Danny Tuppeny shows both Project and External references:

    Function Get-ProjectReferences($rootPath)
    {
      $projectFiles = Get-ChildItem $rootPath -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 {
            "PR:[" + $projectName + "]:[" + $_ + "]"
        }
      }
    
      $projectFiles | ForEach-Object {
        $projectFile = $_ | Select-Object -ExpandProperty FullName
        $projectName = $_ | Select-Object -ExpandProperty BaseName
        $projectXml = [xml](Get-Content $projectFile)
    
        $externalReferences = $projectXml | Select-Xml '//defaultNamespace:Reference/@Include' -Namespace $ns
        $externalReferences | ForEach-Object {
            "ER:[" + $projectName + "]:[" + $_ + "]"
        }
    
      }
    
    }
    
    Get-ProjectReferences "C:\projects" | Out-File "C:\temp\References.txt"
    

    It will give a colon-separated file that can be opened and analysed in Excel.

    0 讨论(0)
  • 2020-11-28 18:14

    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"
    
    0 讨论(0)
  • 2020-11-28 18:15

    You can create a nice graph of the references in your projects. I've described the way I did it on my blog http://www.mellekoning.nl/index.php/2010/03/11/project-references-in-ffffd/

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