Monday, March 14, 2011

NuGet Package Management to the Rescue

I've seen the light.

I am working on a project and needed to include a reference to Castle.Windsor. I thought about all the pain that goes with this. In order to even get Castle.Windsor working, I have to first download it. Place it into a directory on my file system. Then I have to add the reference to my .NET assembly. Once that's done, I have to then modify my web.config file to ensure that everything get's mapped up correctly. Then (and only then) can I try to do a compile and hope I didn't screw something up along the way.

Welcome to NuGet!

With NuGet, I simply go to the Package Management Console toolwindow inside Visual Studio and type:

Get-Package MyProjectName | Install-Package Castle.Windsor -Version 2.5.2


This means:
- Set MyProjectName as the default project
- Pipe that output as the input to the Install-Package command
- Install Castle.Windsor (v2.5.2) along with anything it might depend on

Viola, all that stuff is done for me automagically for me. I see a slew of output in my console window with a final "Done." at the end. Looking through my solution explorer, I see that the references have been added and a few config files were updated. Castle.Windsor is installed and configured.

Since this was so easy, I went so far as to install Elmah next. Installing these two projects into my solution took me less than 10 seconds. Without NuGet, this would have taken me 20-30 minutes and lots of docs-diving.

I'm a NuGet fan!

No comments: