Update – 2019
NuGet is now part of Visual Studio and some of the information described here does not apply anymore.
NuGet is a package management system for the .NET platform, it is supposed to simplify the process of incorporating third-party libraries into a .NET project during development. Basically, it is a great way to add (and update) oopen-sourcelibraries and the like to your .NET project. The first version of NuGet was released in October 2010 and it was originally named NuPack.
How to get it
NuGet can be installed from here or from Visual Studio’s Extension Manager located under the Tools menu.
The awesomeness of it
Before NuGet, the way we incorporated third-party libraries into our projects was by doing the following:
- Download third-party library (and any dependencies) from the web.
- Unpack them (as many of them come in compressed files) to a folder in our project, I usually create (or created) a folder labeled “lib” and placed all the third-party libraries there.
- Import to the .NET project.
- Make any necessary changes to the config file when needed.
The NuGet Gallery
Where does this copy of NUnit comes from you might ask? if you look closely at the image above, you’ll see a Package source field in the upper left corner of the window, this is the default NuGet package source and it basically points to NuGet’s service at http://packages.nuget.org/v1/FeedService.svc/.
These third-party libraries are hosted by Microsoft and the list of third-party libraries available in NuGet increases every day.
As of today, there are 1,418 packages available in NuGet’s official package service. You can browse the different packages available in NuGet by visiting the NuGet website, by opening the Add Library Package Reference located under the Tools menu (Tools – Library Package Manager), the Add Library Package Reference is also available in the Add Reference menu, and my favorite, by typing the command PM> Get-Package -ListAvailable in the Console… if you do this, just have in mind that it will take a while to list all the libraries available 😉
For those who prefer the clicking instead of the typing, the Package Manager Console is your tool, you can access it by typing “manage NuGet packages” in Visual Studio search, it’ll come up right away. You could also right-click on a project and choose the option to manage NuGet packages from there.
From this window, you can see a list of the installed packages, a list of all the packages available, you can search and install any package you might need to as well; this is all in a per-project basis. What this means is that if you have a solution with multiple projects and you want to have a library such as NUnit available to all projects or at least available in more than one project… you’ll have to add it to each individual project – yes! this isn’t ideal, I know.
Phil Haack, Senior Program Manager for the ASP.NET team, recently wrote about the possibility of adding the ability to use a single package version per solution, instead of a project. I think this is a great idea and many people probably won’t start using NuGet in their multi-project solutions until this is available. Phil or @haacked for those who follow him on Twitter, also took the time to add a survey to his blog post and based on the results of this survey, it looks like the majority of the people who responded agree that having the option to have a single NuGet package version per solution is not only ideal, it is necessary.
How to Contribute
You can develop your own NuGet packages and upload them to NuGet.org so they can be shared with others, all you need to do this is to create an account on NuGet.org and then upload your NuGet package. Detailed instructions on how to create a NuGet package can be found here.
Well, that is all I have now regarding NuGet, I do like this tool and I think it will be very useful for all .NET developers. I am working on another post that will show the steps to follow to create your own NuGet server/gallery (yes, the code for the NuGet service is open source and available to anyone interested!), upload your own NuGet packages and make them available to your team. The idea is that a company developing in the .NET platform can take advantage of having their own NuGet service running internally so their developers can share their own class libraries and the like by using NuGet and their local NuGet service/gallery. This is better than shared network folders, emailing dlls, etc…
Software Engineer + Enthusiast Photographer