Udostępnij za pośrednictwem


Introducing NuGet: the smart way to bring bits into your projects

I’m thrilled to announce that the secret project we’ve been working on for the last few months is no longer a secret!  It’s called NuGet, and you can download it from here.  Make sure you also read ScottGu’s post about it.

So what the heck is NuGet?  In short, it’s an Open Source package manager that lets you import libraries into your .NET applications with much less effort than what you’re used to.  Note that NuGet is not a Microsoft project, but an Outercurve Foundation project (previously Codeplex Foundation).  It has both Microsoft and non-Microsoft contributors, and is run as a true Open Source project.  See https://nuget.codeplex.com/ for more info on this.

 

What problem is NuGet solving exactly?

 

If you’re a .NET programmer, you’ve likely experienced the pain of getting a 3rd party library into your project.  It usually goes something like this:

  1. You know what it’s called, but you have no idea where it lives, so you search for it in your favorite engine.  You often find multiple pages that could legitimately be the want you want.
  2. You look around the main page for a link to the download page.
  3. Once on the download page, you’re often presented with way more choices than you’d like: several builds, for several platforms, …
  4. You download a zip file that you then unzip somewhere on your machine (after remembering to ‘unblock’ it in Windows!).
  5. You copy the relevant assemblies into some folder in your solution.
  6. In VS, you add a reference to the assemblies.
  7. In some cases, you need to make changes to your web.config file to properly enable the component.  This is quite non-trivial if you’re not familiar with it.

Needless to say, all of that is pretty painful and error prone.  Sure, once you’re familiar with a library, you’d probably just copy it from another project instead of getting it from the web, which makes things a bit easier.  But it’s still an overall very ad-hoc process.

And that doesn’t even cover the common case where a library has a dependency on some other libraries, which raises the complexity to the next level.

 

NuGet to the rescue!

 

With NuGet, you get a PowerShell window directly in Visual Studio.  You just type a simple command like ‘Add-Package CoolLibrary’, and it takes care of everything.  You can also right click on References and choose ‘Add Package Reference’ to do the same thing through a dialog.  It’s all very very easy, and it just works!

But instead of giving you all the details in writing, I put together a screen cast that shows NuGet in action!  It’s 14 minutes long, so a little bit on the long side, but it demonstrates using NuGet to install all kind of libraries into an MVC 3 app, so it’s pretty action pack.  If that doesn’t convince you of the awesomeness of NuGet, then I will have failed :)

Note: to watch it optimally, you can click on it a second time to view it directly in YouTube.  In there, change it to 720p and play it in full screen.

Another small note is that I made this video with a slightly older build, so you will see some small UI differences with the public bits.

 

NuPack in Action

 

I’ll be blogging some more about NuGet in the coming days, so stay tuned!

Comments

  • Anonymous
    October 06, 2010
    Thanks for the post! Is there any difference as far as the output between using mvcscaffold and using Add->View?

  • Anonymous
    October 06, 2010
    @Ely: it's calling into the same logic, so it should be the same output.

  • Anonymous
    October 06, 2010
    Is this related to "Nu" at all?

  • Anonymous
    October 06, 2010
    @Eber: it's sort of Nu 2.0 :)  All the devs from Nu are involved in NuPack, and there will be conversion tools for the packages.

  • Anonymous
    October 06, 2010
    How do I add my open-source project to the nupack's project feed?

  • Anonymous
    October 06, 2010
    @Scott: for now, just send a pull request to nupackpackages.codeplex.com. Longer term, we'll have a real gallery.

  • Anonymous
    October 06, 2010
    nice ! merci !

  • Anonymous
    October 06, 2010
    Is this for asp.net applications only? All the videos and posts seem to focus on web apps...

  • Anonymous
    October 06, 2010
    @Paul: it actually works on any type of app: Console, Silverlight, ...  We should try to demo those scenarios as well.  But generally, it works the same way.

  • Anonymous
    October 07, 2010
    How about updates of a librabry? Will/can you be notified when newer versions exist to pull them into your project? // Ryan

  • Anonymous
    October 08, 2010
    @Ryan: yest, updates are supported, but I didn't get to show them in my demo.  Try 'list-package -update', and then 'update-package [name]'.