Skip to content

Instantly share code, notes, and snippets.

View zhangr4's full-sized avatar

zhangr4 zhangr4

View GitHub Profile
@zhangr4
zhangr4 / Generate-CsProjDependencyGraph.ps1
Created February 14, 2025 04:01
Generate Project Dependency of a CSharp project to dot file, which can be visualized by graphviz
$projects = Get-ChildItem -Recurse -Filter *.csproj # find all csharp project recursively from current working path
$dotFile = "dependencies.dot" # file name of generated dot file
$edges = @() # represent edges as an array of objects
foreach ($project in $projects) {
$projectXml = [xml](Get-Content $project.FullName) # parse .csproj as xml
$projectDir = Split-Path -Parent $project.FullName
$references = $projectXml.Project.ItemGroup.ProjectReference # get project references of $project