Tuesday 21 May 2013

Saving the entire list of NuGet Packages

Following from Retrieving NuGet package programatically using NuGet.exe classes (not command line), here is the script that downloads and saves the raw http responses (from the request used by the NuGet API to get them)


image

The scripts’s execution creates this:

image

Problem I had when when trying to percist the data generated from the Nuget.exe APIs (which required me to do the direct download described above)

Once we have a nice Package object in memory, it would be great if we could to just save it to disk (to persist it).

But unfortunately, XML serialization:

image_thumb[58]

... Json Serialization:
image_thumb[59]

....and binary serialization fail:

image_thumb[61]

Since serialization doesn’t work another alternative would be to use the NuGet SharedPackageRepository object

image_thumb[54]

which will create

 image_thumb[55]

which contains:

image_thumb[56]

but the object data after the save is not as rich as before

image_thumb[53]

Since they are different types (ShareOptimizedZipPack is shown above on the left, and DataServicePackage on the right)

image_thumb[57]


See also Offline copy of the entire NuGet.org gallery. What should I do with these 4.05 Gbs of amazing .Net Apps/APIs?