You Really Should Be Using NuGet

If you get one thing out of this post, I want it to be that you need to help spread the word on NuGet.

If you are currently using Visual Studio 2010, you have a very powerful package manager at your fingertips. What is a package manager? Well, you know how when you want to use a third party library you have to go find the website, download all of the files, unzip them somewhere (don’t forget to right click and "unprotect" that zip file!), copy them into your project, add references to them, add some configuration, and then you can finally use your library.

Then when a new version comes out (which you probably don’t know about), you have to do the whole thing all over again! It SUCKS. The Ruby guys haven’t had to deal with this for a loooooong time. It has taken a long time for us to get there.


How To Get It

Okay, enough chat, how do you get it? Well, just head over to Visual Studio and click Tools > Extension Manager. Then go to "Online Gallery". Once you are there, search for NuGet. Then all you have to do is click install:

image

That is it, you can use it now. And using it is just as easy.

How To Use It

The easiest way to use NuGet is to right click on the project "References" folder and clicking "Add Library Package Reference…":

image

This will pop up a box that looks like the Visual Studio Plugins Gallery. Just click the "Online" entry on the left:

image

And then you will see a list of packages. There is already over 750 packages at the time of writing, with more being added every day (25 today actually).

If you want to add a package, like say the Mongo drivers from 10gen, all I have to do is search for "Mongo" in the top right corner of the dialog and I’ll see a list of packages which match my search:

image

Then I just click the install button. My references are added just like that (and configuration if the package includes it):

image

And now when the package is updated, I can simply go back to the NuGet dialog and on the left click the "Updates" option. It will show you all packages that have available updates. All you have to do is click a button to update to the latest version of the package (I don’t have any currently available):

image

You can also optionally use the console if you don’t want to use the GUI. Just go to Tools > Library Package Manager > Package Manager Console

image

You’ll then get a console that looks like this:

image

You’ll have a few commands available to you, like Install-Package. You can even use tab completion which will search online! Check it out:

image

You can also use Uninstall-Package, Update-Package, or Get-Package. Get-Package is really useful for doing searches:

image

I hope you see now just how awesome NuGet is, and I hope that you’ll go check it out and spread the word. NuGet has the potential to really help push open source on the .NET platform and at the same time make your life much easier. I highly recommend that you go grab it now.

Be Sociable, Share!

Tags: ,

14 comments

  1. Small typo in the blog post. There’s no Remove-Package it’s Uninstall-Package

  2. Justin Etheredge

    Thanks, Remove-Package was the old command.

  3. Went to add SquishIt to a new project last week via NuGet ;)

  4. Justin Etheredge

    @Paul Yeah yeah yeah, I’m getting around to it. :-)

  5. Nice writeup Justin! I think I’ll put an FAQ up on our site and point to this.

  6. Justin Etheredge

    @Peter Sounds good to me! Thanks!

  7. Thanks for the great write-up! :)

  8. I went with openwarp due to the implementation. I have not been let down.

  9. I am helping spread the word over at my blog… http://bit.ly/info/eDd4sb

  10. When will SourceGear Vault work with nuget packages? Could it be done better to work with more source control providers? I wish my projects would stop breaking when I try to work with them on another computer…

  11. Cool. Does NuGet offer anything to help when it’s time to install your program on end-user machines?

  12. Justin Etheredge

    Nope, NuGet is only for tools distribution, not end user application distribution.

  13. Why is something like NuGet is seen as useful? Why do we want a tool that inserts hidden references and links all over my computer? I just want the dll. I don’t want my PC and project files tampered with.

    In any enterprise development environment, dependencies have to be managed as part of the build and deployment system. A ‘convenience’ like NuGet for developers is no convenience at all unless you truly never give your software to anybody else to use.

  14. @Bob W, my thoughts EXACTLY!

    I am a minimalist and can’t stand all the needless crap Nuget downloads and sets up.

Leave a comment