Unlist.ps1
· 2.1 KiB · PowerShell
原始文件
# 示例:对多个包执行Unlist操作
$packages = @(
"Aiursoft.Archon.SDK",
"Aiursoft.Developer.SDK",
"Aiursoft.Directory.SDK",
"Aiursoft.DocGenerator.Abstract",
"Aiursoft.DotDownload.Core",
"Aiursoft.Dotlang.Core",
"Aiursoft.Gateway.SDK",
"Aiursoft.Handler",
"Aiursoft.Handler.Abstract",
"Aiursoft.Pylon",
"Aiursoft.SDK",
"Aiursoft.SDK.Tests",
"Aiursoft.SDKTools",
"Aiursoft.SnakeGame",
"Aiursoft.Stargate.SDK",
"Aiursoft.Status.SDK",
"Aiursoft.UiStack",
"Aiursoft.Wrapgate.SDK",
"Aiursoft.XelNaga",
"AiurVersionControl",
"AiurVersionControl.CRUD",
"Anduin.HappyRecorder.Calendar",
"Anduin.HappyRecorder.PluginFramework",
"Anduin.QRCoder",
"Anduin.QRCoder.NET",
"Crawler.CLTeans",
"Crawler.FantasticBodies",
"Crawler.FlexyTeens",
"Crawler.Shared",
"DemoApiApp.Sdk",
"Diff4Net.Core",
"Kahla.SDK",
"MoongladePure.Comments",
"MoongladePure.Configuration",
"MoongladePure.Core",
"MoongladePure.Data",
"MoongladePure.Data.MySql",
"MoongladePure.FriendLink",
"MoongladePure.ImageStorage",
"MoongladePure.Syndication",
"MoongladePure.Theme",
"MoongladePure.Utils",
"MoongladePure.Web",
"NiBot"
)
$apiKey = "aaaaaaaaaaaaaaaaaaaaaaaaa"
function Remove-AllNuGetPackageVersions($PackageIds, $ApiKey)
{
foreach ($PackageId in $PackageIds) {
$lower = $PackageId.ToLowerInvariant()
try {
$json = Invoke-WebRequest -Uri "https://api.nuget.org/v3-flatcontainer/$lower/index.json" -ErrorAction Stop | ConvertFrom-Json
foreach ($version in $json.versions) {
Write-Host "Unlisting $PackageId, Version $version"
Invoke-Expression "dotnet nuget delete $PackageId $version --non-interactive --api-key $ApiKey --source https://api.nuget.org/v3/index.json"
Start-Sleep -Seconds 10
}
}
catch {
Write-Host "Error unlisting $PackageId $_" -ForegroundColor Red
}
}
}
Remove-AllNuGetPackageVersions -PackageIds $packages -ApiKey $apiKey
1 | # 示例:对多个包执行Unlist操作 |
2 | $packages = @( |
3 | "Aiursoft.Archon.SDK", |
4 | "Aiursoft.Developer.SDK", |
5 | "Aiursoft.Directory.SDK", |
6 | "Aiursoft.DocGenerator.Abstract", |
7 | "Aiursoft.DotDownload.Core", |
8 | "Aiursoft.Dotlang.Core", |
9 | "Aiursoft.Gateway.SDK", |
10 | "Aiursoft.Handler", |
11 | "Aiursoft.Handler.Abstract", |
12 | "Aiursoft.Pylon", |
13 | "Aiursoft.SDK", |
14 | "Aiursoft.SDK.Tests", |
15 | "Aiursoft.SDKTools", |
16 | "Aiursoft.SnakeGame", |
17 | "Aiursoft.Stargate.SDK", |
18 | "Aiursoft.Status.SDK", |
19 | "Aiursoft.UiStack", |
20 | "Aiursoft.Wrapgate.SDK", |
21 | "Aiursoft.XelNaga", |
22 | "AiurVersionControl", |
23 | "AiurVersionControl.CRUD", |
24 | "Anduin.HappyRecorder.Calendar", |
25 | "Anduin.HappyRecorder.PluginFramework", |
26 | "Anduin.QRCoder", |
27 | "Anduin.QRCoder.NET", |
28 | "Crawler.CLTeans", |
29 | "Crawler.FantasticBodies", |
30 | "Crawler.FlexyTeens", |
31 | "Crawler.Shared", |
32 | "DemoApiApp.Sdk", |
33 | "Diff4Net.Core", |
34 | "Kahla.SDK", |
35 | "MoongladePure.Comments", |
36 | "MoongladePure.Configuration", |
37 | "MoongladePure.Core", |
38 | "MoongladePure.Data", |
39 | "MoongladePure.Data.MySql", |
40 | "MoongladePure.FriendLink", |
41 | "MoongladePure.ImageStorage", |
42 | "MoongladePure.Syndication", |
43 | "MoongladePure.Theme", |
44 | "MoongladePure.Utils", |
45 | "MoongladePure.Web", |
46 | "NiBot" |
47 | ) |
48 | |
49 | |
50 | $apiKey = "aaaaaaaaaaaaaaaaaaaaaaaaa" |
51 | |
52 | function Remove-AllNuGetPackageVersions($PackageIds, $ApiKey) |
53 | { |
54 | foreach ($PackageId in $PackageIds) { |
55 | $lower = $PackageId.ToLowerInvariant() |
56 | |
57 | try { |
58 | $json = Invoke-WebRequest -Uri "https://api.nuget.org/v3-flatcontainer/$lower/index.json" -ErrorAction Stop | ConvertFrom-Json |
59 | |
60 | foreach ($version in $json.versions) { |
61 | Write-Host "Unlisting $PackageId, Version $version" |
62 | Invoke-Expression "dotnet nuget delete $PackageId $version --non-interactive --api-key $ApiKey --source https://api.nuget.org/v3/index.json" |
63 | Start-Sleep -Seconds 10 |
64 | } |
65 | } |
66 | catch { |
67 | Write-Host "Error unlisting $PackageId $_" -ForegroundColor Red |
68 | } |
69 | } |
70 | } |
71 | |
72 | Remove-AllNuGetPackageVersions -PackageIds $packages -ApiKey $apiKey |
73 | |
74 |