Tuesday 21 May 2013

Consuming NuGet programmatically outside VisualStudio (downloading the list of packages)

I wanted to write an O2 Script today that consumed an NuGet package and was annoyed by the fact that there doesn’t seem to be an easy way to just download and consume the dlls directly (i.e. without VisualStudio).

I did a quick search and although it looks like I’m not the only one with this problem, since there isn’t an easy solution out there:
So the solution was to add support for it the O2 Platform :)


I had already tried to do this in the past, and before I run out of time, I did managed to create a couple scripts:

image

The NuGet_Installer.cs is a typical (O2 based) installer script that will download Nuget …

image

… and put it on the _ToolsOrApis folder:

image

The API_Nuget.cs is basically an process/console-out wrapper of the nuget.exe process

image

with a bunch of Extension Methods to help with the command line invocation of NuGet.exe

image

But this is not what I want. I need to execute and consume the NuGet classes directly.

Which means to access the Commands available in NuGet programatically and recreate the NuGet API’s extension methods.

And that is what I describe in Retrieving NuGet package programatically using NuGet.exe classes (not command line)

Note that the API_NuGet.cs is not completed at this stage (that will be shown in a future post)


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