Created
November 28, 2023 23:27
-
-
Save jonnekleijer/24a90ac4fc28246aa7406d52f12a5599 to your computer and use it in GitHub Desktop.
Update all csproj package references
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
| $regex = 'PackageReference Include="([^"]*)" Version="([^"]*)"' | |
| ForEach ($file in get-childitem . -recurse | Where-Object { $_.extension -like "*proj" }) { | |
| $packages = Get-Content $file.FullName | | |
| select-string -pattern $regex -AllMatches | | |
| ForEach-Object { $_.Matches } | | |
| ForEach-Object { $_.Groups[1].Value.ToString() } | | |
| Sort-Object -Unique | |
| ForEach ($package in $packages) { | |
| write-host "Update $file package :$package" -foreground 'magenta' | |
| $fullName = $file.FullName | |
| Invoke-Expression "dotnet add $fullName package $package" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment