-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathupdateNuget.ps1
More file actions
23 lines (20 loc) · 913 Bytes
/
updateNuget.ps1
File metadata and controls
23 lines (20 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# PowerShell script to update NuGet packages in all project files
# This script finds all .csproj and .fsproj files and updates stable (non-prerelease) packages
$regex = 'PackageReference Include="([^"]*)" Version="([^"]*)"'
Get-ChildItem -Path . -Recurse -Include "*.csproj", "*.fsproj" | ForEach-Object {
$projFile = $_.FullName
Write-Host "Processing project: $projFile"
$content = Get-Content $projFile
foreach ($line in $content) {
if ($line -match $regex) {
$packageName = $matches[1]
$version = $matches[2]
Write-Host "Found package: $packageName, version: $version"
# Only update stable versions (not prerelease versions containing -)
if ($version -notmatch '-') {
Write-Host "Updating package: $packageName"
dotnet add "$projFile" package "$packageName"
}
}
}
}