NuGet is a Visual Studio extension that enables you to download and use shared code libraries with the Microsoft development community.
This is Microsoft’s attempt to benefit from a large development community and pool of shared code, a concept enjoyed by many open source communities such as Drupal and Ruby on Rails.
The extension will manage the installation of libraries, files, references and any necessary configuration in the form of “packages” that can be added or removed.
NuGet is a free, open source developer focused package management system for the .NET platform intent on simplifying the process of incorporating third party libraries into a .NET application during development
With the Release of NuGet 1.2 the system has matured by allowing packages to specify the version of the .Net framework they are referencing types from, automatic binding redirects for the times where a package needs a different assembly version from the one that is currently being used as well as allowing the package to separate libraries for different platforms such as Windows Phone 7.
In this post I’ll step though how to install NuGet and utilize one of the many packages available. In a future post I’ll descript how to create your own package to share with the community.
NuGet runs on any commercial edition of Visual Studio 2010 or Visual Studio Express 2010 Visual Web Developer. Other express editions are not currently supported.
To install NuGet, open the Extension Manager in the tools menu in Visual Studio.
Click the Online Gallery on the left side, then type “NuGet” in the Search Online Gallery field.
Click the Download button on the NuGet Package Manager. After the installation you will need to restart Visual Studio
After you’ve installed NuGet you have access to a library of hundreds of community developed packages. A gallery of which can be found here: http://nuget.org/
To install a package, right-click on the project you wish to add a package to and select “Add Library Package Reference…”, click “online” and search for the name of the package to use.
An example is the Fackbook.Helper package that makes it easy to add interactive Facebook controls. http://facebookhelper.codeplex.com/
Once you click install, the files included in the package are downloaded and automatically added to your project. A packages.config will also appear in your project and will display the packages used.
I have found however that in the case of some packages, not all the assemblies the package uses are added to the project’s references. In these cases I’ve had to manually add the references they need. Even then, sometimes not all the required assemblies are in the Global Assembly Cache (GAC). In these cases you should switch Copy Local in the referenced DLL’s properties to True so that the assembly is coped to your bin folder at build time.
Now once the Fackbook.Helper package is installed, I can easily add a facebook “like” button with the razor code:
@Facebook.LikeButton(URL to like)
ViewBag.Title = "Home Page";
<h2>NuGet 1.2 Facebook.Helper Test</h2>
The result is a Facebook like button with precious little effort.
NuGet is in its relative infancy but already has over a thousand packages to explore. It is a welcome recognition by Microsoft of the strength of an open source community and the benefits for its developers.
New users should look at the Getting Started page and the Nuget documentation.
Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.
We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats or subscription fees.
If you like our content, and would like to help, please consider making a contribution:
Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.