Wednesday, May 22, 2013

Download and Export NuGet Packages Without VS.NET

99.999% of the NuGet packages that I use are associated with a specific project in VS.NET and adding them with the Package Manager Console is trivial.  Just copy and paste the command from the NuGet site, and your done.

Interestingly enough though I came across a couple of utilities I wanted to use that were hosted on NuGet that were not application specific; specifically 'OpenCover' and 'ReportGenerator'. These are used for unit testing code coverage metrics and reporting, so I thought they needed to be added to my unit test project. After seeing how they worked I realized they had nothing to do with any project and could be downloaded independently. I can still use VS.NET to download the packages and then move them, but why clutter my app with packages that are truly not required.

There is an easy enough way to download NuGet packages separate from VS.NET and export their contents to any given directory. One method I want to show you is a quick way to download a package from NuGet without any tooling at all, and just using the browser. Find the name of your package from NuGet and append it on to the end of this URL:{package name}
and then add the package to make the complete download URL like this:

Which will immediately result in the download of the .nupkg NuGet package:

Now that's a quick and easy way to get the NuGet package without VS.NET. However there is a more inclusive tool named 'NuGet Package Explorer' available from CodePlex which allows us to download and export directly. This tool can be downloaded from the following link:

NuGet Package Explorer

It's a ClickOnce package and once installed there should be a desktop icon to launch the tool:

The easier way to download a package is to select 'Open a package from online feed' from the dialog presented upon opening the application. However if you already have the package downloaded you can select the 'Open a local package' link instead:

Search for the package you wish to download and extract:

Once you select the package you are looking for and press 'OK', the package's contents will be shown. Go to FILE -> Export where you can select the export location of the package:

Upon successful export of the NuGet package you should see the following message:

Lastly, navigate to the export location you selected and verify the contents of the NuGet package exist:

That's it! There is other functionality of the Package Explorer that includes making your own NuGet package as well. However it is possible to download and easily export the contents of a NuGet package without using VS.NET.

No comments:

Post a Comment