At its core, NuGet is a package manager for .NET. In the past, if you wanted to incorporate an asset into your solution, you would generally find the library online, download it, read the documentation, copy it over to your project, and then make whatever changes were necessary to your configuration files to get it to work. NuGet simplifies this process in two primary ways. First, there is now a central repository for many common components packaged into NuGets. Second, upgraded tooling is now available in Visual Studio to find and incorporate these packages into your solution without any work on your part. Think of it like an “Add/Remove Programs” feature built into your Visual Studio that can add things like jQuery or ELMAH.
First things first, you need to get NuGet. To do so, open Visual Studio, click Tools -> Extension Manager -> Online Gallery. Now install NuGet.
Once you have NuGet, open a project in Visual Studio and in your Solution Explorer, right click on the References folder (If you cant see your References folder, click the little ‘Show All Files button’ at the top of the solution explorer).
Choose Manage Packages. This will bring up a window that will allow you to search for available NuGet packages and install them into your solution. You can either search the official NuGet Gallery, or look at your own (assuming you set your own up). In fact, there is even a NuGet package of a NuGet Server application available for download.
But wait, that’s not all. The truth is you don’t even need to use the GUI tools to work with NuGet. This is because you now also have Power Shell integration in Visual Studio. You can use Power Shell to deal directly with NuGet Packages. While you may not have a need to do so, this feature is still awesome, because if your like me and run network related commands from a command prompt sometimes during the day, you can do it directly in Visual Studio now. I have a feeling TFS users are going to love this feature.
To be honest, this post just scratches the surface. If you want to know more, watch this video with Scott Hanselman and Phil Haack. Even if you don’t want to know more, watch the video anyway, because its probably the most entertaining presentation you will see this year.
- Michael Ossou