Thursday, 7 February 2013

How do you install a NuGet package in Visual Studio 2012

This is the first of a brand new series of videos that I am producing for my new YouTube channel HowDoYouDoStuff.

A channel dedicated to short videos on how to do stuff.

In this video, I show you how to install a NuGet package into your project in Visual Studio 2012.

You can read the transcript below.

HTML5 player


In this video, I am going to show you how simple it is to add a NuGet package into your project in Visual Studio 2012.

Although I am using Visual Studio 2012, the process is almost identical in 2010.

NuGet is a Visual Studio extension that provides a delivery mechanism to add packages stored in the cloud into your projects.

Typically, adding a component to your project would involve downloading an installer, running it then adding a reference to the dll in your project. You might also have to add something to your config file.

NuGet manages this whole process for you.

You launch NuGet either by right-clicking the References node in your project and selecting Manage NuGet Packages or by selecting the same option from the Tools \ Library Package Manager menu.

The NuGet window lists any packages that have already been installed and will let you check online for an additional package to install.

This project is an MVC 3 project to which I would like to add the RouteDebugger package.

As I know what I am after, I can search for it by name.

Anyone can create a package and submit it to NuGet so you might want to consider the package's origin.

I can see by the profile to the right that this package was created by Phil Haack, one of the MVC team at Microsoft so I am pretty happy to use his package.

To install the package, I need simply click on the Install button.

As you can see, it doesn't take long to install. Although, the time taken will depend on the size of the actual package.

Now that I have installed the package, let's see what just happened.

As you might expect, many packages are delivery mechanisms for dlls or assemblies and if I expand the References node, you can see that the RouteDebugger assembly has been added to my project.

If I open the project folder in Windows explorer, I will be able to show you where NuGet has placed the assembly.

It is stored in a Packages folder below the solution folder.

Let me switch back into Visual Studio 2012 to show you something else.

The RouteDebugger component requires some configuration. If I open web.config, you can see that NuGet has placed the required entry in the file for me.

There you have it.

In this video, I have shown you how easy it is to add a NuGet package to your Visual Studio 2012 project. It can be used to add a wide variety of assets to your projects.

Flash player

See you soon

Phil Stirpé
"I don't do average!"

No comments:

Post a Comment