-
-
Save crunchie84/4509520 to your computer and use it in GitHub Desktop.
dependecy graph yuml generator for c# projects fork from http://blog.dantup.com/2012/05/free-dependency-graph-generation-using-powershell-and-yuml
Tweaked because my powershell gave some errors about missing values for Mandatory attribute and ValueFromPipeline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-ProjectReferences | |
{ | |
param( | |
[Parameter(Mandatory=$True)] | |
[string]$rootFolder, | |
[string[]]$excludeProjectsContaining | |
) | |
dir $rootFolder -Filter *.csproj -Recurse | | |
# Exclude any files matching our rules | |
where { $excludeProjectsContaining -notlike "*$($_.BaseName)*" } | | |
#Write-Host | |
Select-References $excludeProjectsContaining | |
} | |
function Select-References | |
{ | |
param( | |
[string[]]$excludeProjectsContaining, | |
[Parameter(ValueFromPipeline=$True, Mandatory=$True)] | |
[System.IO.FileInfo]$project | |
) | |
process | |
{ | |
if($excludeProjectsContaining -like $_.BaseName){ | |
return; | |
} | |
$projectName = $_.BaseName | |
[xml]$projectXml = Get-Content $_.FullName | |
$ns = @{ defaultNamespace = "http://schemas.microsoft.com/developer/msbuild/2003" } | |
$projectXml | | |
# Find the references xml nodes | |
Select-Xml '//defaultNamespace:ProjectReference/defaultNamespace:Name' -Namespace $ns | | |
# Get the node values | |
foreach { $_.node.InnerText } | | |
# Exclude any references pointing to projects that match our rules | |
where { $excludeProjectsContaining -notlike "*$_*" } | | |
# Output in yuml.me format | |
foreach { "[" + $projectName + "] -> [" + $_ + "]" } | |
} | |
} | |
$excludedProjects = "MockImplementation", "MyProject.IntegrationTests","MyProject.UnitTests" | |
Get-ProjectReferences "C:\development\negentwee\NegenTwee\src\Shared" -excludeProjectsContaining $excludedProjects | Out-File "C:\development\negentwee\NegenTwee\Project-References.txt" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment