Created
March 9, 2023 22:03
-
-
Save decriptor/b91ce4e285e6fe7f4a4b9ef2946902f9 to your computer and use it in GitHub Desktop.
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
Param( | |
[Parameter(Mandatory=$true)] | |
[string]$SolutionFilePath | |
) | |
# Get all lines that start with "Project(" | |
$projectLines = Get-Content $SolutionFilePath | Where-Object { $_ -match '^Project\(' -and $_ -match '\.csproj"' } | |
# Extract project names and paths | |
$projects = $projectLines | ForEach-Object { | |
$matches1 = $_ -match '^Project\("([^"]+)"\) = "([^"]+)", "([^"]+)", "([^"]+)"$' | |
[PSCustomObject]@{ | |
TypeGuid = $matches1[1] | |
Name = $matches1[2] | |
Path = $matches1[3] | |
Guid = $matches1[4] | |
} | |
} | |
# Loop through each project and extract package references | |
foreach ($project in $projects) { | |
Write-Host "Project: $($project.Name)" | |
$csprojPath = Join-Path (Split-Path $SolutionFilePath) $project.Path | |
$packageReferences = Get-Content $csprojPath | Where-Object { $_ -match '<PackageReference Include="([^"]+)" Version="([^"]+)"' } | ForEach-Object { | |
$matches1 = $_ -match '<PackageReference Include="([^"]+)" Version="([^"]+)"' | |
[PSCustomObject]@{ | |
Name = $matches1[1] | |
Version = $matches1[2] | |
} | |
} | |
$packageReferences | Format-Table -AutoSize | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment