Skip to content

Instantly share code, notes, and snippets.

@dstockhammer
Last active February 25, 2024 18:44
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dstockhammer/059d5ef6b9b6b3870e40e75a62a25a4d to your computer and use it in GitHub Desktop.
Save dstockhammer/059d5ef6b9b6b3870e40e75a62a25a4d to your computer and use it in GitHub Desktop.
Unlist all versions of a NuGet package
$PackageId = "xxx"
$ApiKey = "yyy"
$json = Invoke-WebRequest -Uri "https://api.nuget.org/v3-flatcontainer/$PackageId/index.json" | ConvertFrom-Json
foreach($version in $json.versions)
{
Write-Host "Unlisting $PackageId, Ver $version"
Invoke-Expression ".\nuget.exe delete $PackageId $version $ApiKey -source https://api.nuget.org/v3/index.json -NonInteractive"
}
@SchlenkR
Copy link

Thanks for your GIST - it helped me!

Here's an updated version using dotnet nuget:

$packageId = "<YOUR-PACKAGE-NAME>"
$apiKey = "<UNLIST-API-KEY>"

$json = Invoke-WebRequest -Uri "https://api.nuget.org/v3-flatcontainer/$PackageId/index.json" | ConvertFrom-Json

foreach($version in $json.versions)
{
  Write-Host "Unlisting $packageId, Ver $version"
  dotnet nuget delete $packageId $version --source https://api.nuget.org/v3/index.json --non-interactive --api-key $apiKey
}

@Dynesshely
Copy link

Thanks for your GIST - it helped me too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment