-
-
Save SteveH3032/16a0343858bdcd0ae321f0f599539af4 to your computer and use it in GitHub Desktop.
$indexClient = new-object system.net.webclient | |
$jsonIndex=$indexClient.DownloadString("https://api.nuget.org/v3/catalog0/index.json") | ConvertFrom-Json | |
for ($h=0; $h -lt $jsonIndex.items.Length; $h++) { | |
$web_client = new-object system.net.webclient | |
$jsonObj=$web_client.DownloadString($jsonIndex.items[$h].'@id') | ConvertFrom-Json | |
for ($i=0; $i -lt $jsonObj.items.Length; $i++) { | |
$package = $jsonObj.items[$i]."nuget:id" + "/" + $jsonObj.items[$i]."nuget:version" | |
$web_client.DownloadFile("https://www.nuget.org/api/v2/package/" + $package, ("C:\Nuget\" + $jsonObj.items[$i]."nuget:id" + "." + $jsonObj.items[$i]."nuget:version" + ".nupkg")) | |
"Processing: " + ($h + 1) + " of " + $jsonIndex.count + " ---- " + ($i + 1) + " of " + $jsonObj.count + " - " + $jsonObj.items[$i]."nuget:id" + "." + $jsonObj.items[$i]."nuget:version" | |
} | |
} |
Thanks JerkerPihl. Only after running this did I notice the statement "Because the catalog is not used by the official NuGet client, not all package sources implement the catalog." on the site https://docs.microsoft.com/en-us/nuget/api/catalog-resource.
So I offer the following:
Step 1 - Open Visual Studio 2017
Step 2 - Open the NuGet Package Manager Console
a. Click the Tools menu
b. Click NuGet Package Manager
c. Click Package Manager Console
Step 3 - Enter the following command:
Get-Package -ListAvailable -PageSize 122831 | Export-Csv -Path "C:\NugetList\NuGet_All.csv"
Step 4 - Run the following
`
$path = "C:\NuGetList\NuGet_All.csv"
Import-Csv $path | Foreach-Object {
$url = "https://www.nuget.org/api/v2/package/$($_.id)/$($_.version)"
(New-Object System.Net.WebClient).DownloadFile($url, $output)
}
Running the script above in Powershell I get the following error:
$.id : The term '$.id' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At E:\Nuget_All.ps1:4 char:29
+ $OUTPUT = "E:\Nuget$\Nuget$($.id).$($.version).nupkg"
+ ~~~~
+ CategoryInfo : ObjectNotFound: ($.id:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
$.version : The term '$.version' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At E:\Nuget_All.ps1:4 char:37
+ $OUTPUT = "E:\Nuget$\Nuget$($.id).$($.version).nupkg"
+ ~~~~~~~~~
+ CategoryInfo : ObjectNotFound: ($.version:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
$webClient should be $web_client