Created
March 16, 2023 19:50
-
-
Save tkapin/e6978cec9e5fde45281618f1fb57068e to your computer and use it in GitHub Desktop.
Arcade services project references
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
param( | |
[string]$Path = $(Get-Location) | |
) | |
Set-StrictMode -Version 3.0 | |
# Crude script for mapping project references in VS solution | |
Function Mermaidify([string] $str) { | |
return "$($str.Replace(".","_"))" | |
} | |
Function Get-ProjectReferences($rootFolder) | |
{ | |
Write-Output "flowchart LR" | |
$projectFiles = Get-ChildItem $rootFolder -Filter *.csproj -Recurse | |
# clusters representing paths | |
$subgraphs = @{} | |
foreach($projectFile in $projectFiles) { | |
$parentDirName = $projectFile.Directory.Parent.Name | |
if ($subgraphs[$parentDirName]) { | |
$subgraphs[$parentDirName] += $projectFile.BaseName | |
} else { | |
$subgraphs[$parentDirName] = @($projectFile.BaseName) | |
} | |
} | |
foreach($subgraph in $subgraphs.GetEnumerator()) { | |
Write-Output "subgraph $(Mermaidify($subgraph.Name))_cluster[$($subgraph.Name)]" | |
foreach ($node in $subgraph.Value) { | |
Write-Output " $(Mermaidify($node))[$node]" | |
} | |
Write-Output "end" | |
} | |
# dependencies | |
foreach($projectFile in $projectFiles) { | |
$projectName = $projectFile.BaseName | |
$projectReferenceNodes = Select-Xml -Path $projectFile.FullName -XPath "/Project/ItemGroup/ProjectReference/@Include" | |
foreach($projectReferenceNode in $projectReferenceNodes) { | |
$projectReference = [System.IO.Path]::GetFileNameWithoutExtension($projectReferenceNode.Node.Value) | |
Write-Output "$(Mermaidify($projectName))-->$(Mermaidify($projectReference))" | |
} | |
} | |
} | |
Get-ProjectReferences $Path |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment