Skip to content

Commit 40be08b

Browse files
committed
Fixing versions 3
1 parent ac48549 commit 40be08b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

delist-nuget.ps1

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
$apiKey = "key" # Replace with your actual API key
2+
# Unlist all packages matching "2.0.0-v2-develop.*"
3+
# PowerShell script to unlist NuGet packages using dotnet CLI
4+
$packageId = "terminal.gui" # Ensure this is the correct package name (case-sensitive)
5+
$packagePattern = "^2\.0\.0-v2-develop\..*$" # Regex pattern for filtering versions
6+
$nugetSource = "https://api.nuget.org/v3/index.json"
7+
8+
# Fetch package versions from NuGet API
9+
$nugetApiUrl = "https://api.nuget.org/v3-flatcontainer/$packageId/index.json"
10+
Write-Host "Fetching package versions for '$packageId'..."
11+
12+
try {
13+
$versionsResponse = Invoke-RestMethod -Uri $nugetApiUrl
14+
$matchingVersions = $versionsResponse.versions | Where-Object { $_ -match $packagePattern }
15+
} catch {
16+
Write-Host "Error fetching package versions: $_"
17+
exit 1
18+
}
19+
20+
if ($matchingVersions.Count -eq 0) {
21+
Write-Host "No matching packages found for '$packageId' with pattern '$packagePattern'."
22+
exit 0
23+
}
24+
25+
# Unlist each matching package version
26+
foreach ($version in $matchingVersions) {
27+
Write-Host "Unlisting package: $packageId - $version"
28+
dotnet nuget delete $packageId $version --source $nugetSource --api-key $apiKey --non-interactive
29+
}
30+
31+
Write-Host "Operation complete."

0 commit comments

Comments
 (0)