Introducing NuGet Package Manager

NuGet (recently renamed from NuPack) is a free open source developer focused package manager intent on simplifying the process of incorporating third party libraries into a .NET application during development.

After several months of work, the Outercurve Foundation (formerly CodePlex Foundation) today announced the acceptance of the NuGet project to the ASP.NET Open Source Gallery. This is another contribution to the foundation by the Web Platform and Tools (WPT) team at Microsoft.

Also be sure to read Scott Guthrie’s announcement post and Scott Hanselman’s NuGet walkthrough. There’s also a video interview with me on Web Camps TV where I talk about NuGet.

nuget-229x64Just to warn you, the rest of this blog post is full of blah blah blah about NuGet so if you’re a person of action, feel free to go:

Now back to my blabbing. I have to tell you, I’m really excited to finally be able to talk about this in public as we’ve been incubating this for several months now. During that time, we collaborated with various influential members of the .NET open source community including the Nu team in order to gather feedback on delivering the right project.

What Does NuGet Solve?

The .NET open source community has churned out a huge catalog of useful libraries. But what has been lacking is a widely available easy to use manner of discovering and incorporating these libraries into a project.

Take ELMAH, for example. For the most part, this is a very simple library to use. Even so, it may take the following steps to get started:

  1. You first need to discover ELMAH somehow.
  2. The download page for ELMAH includes multiple zip files. You need to make sure you choose the correct one.
  3. After downloading the zip file, don’t forget to unblock it.
  4. If you’re really careful, you’ll verify the hash of the downloaded file against the hash provided by the download page.
  5. The package needs to be unzipped, typically into a lib folder within the solution.
  6. You’ll then add an assembly reference to the assembly from within the Visual Studio solution explorer.
  7. Finally, you need to figure out the correct configuration settings and apply them to the web.config file.

That’s a lot of steps for a simple library, and it doesn’t even take into account what you might do if the library itself depends on multiple other libraries.

NuGet automates all of these common and tedious tasks, allowing you to spend more time using the library than getting it set up in your project.

NuGet Guiding Principles

I remember several months ago, Hot on the heels of shipping ASP.NET MVC 2, I was in a meeting with Scott Guthrie (aka “The Gu”) reviewing plans for ASP.NET MVC 3 when he laid the gauntlet down and said it was time to ship a package manager for .NET developers. The truth was, it was long overdue.

I set about doing some research looking at existing package management systems on other platforms for inspiration such as Ruby Gems, Apt-Get, and Maven. Package Management is well trodden ground and we have a lot to learn from what’s come before.

After this research, I came up with a set of guiding principles for the design of NuGet that I felt specifically addressed the needs of .NET developers.

  1. Works with your source code. This is an important principle which serves to meet two goals: The changes that NuGet makes can be committed to source control and the changes that NuGet makes can be x-copy deployed. This allows you to install a set of packages and commit the changes so that when your co-worker gets latest, her development environment is in the same state as yours. This is why NuGet packages do not install assemblies into the GAC as that would make it difficult to meet these two goals. NuGet doesn’t touch anything outside of your solution folder. It doesn’t install programs onto your computer. It doesn’t install extensions into Visual studio. It leaves those tasks to other package managers such as the Visual Studio Extension manager and the Web Platform Installer.
  2. Works against a well known central feed. As part of this project, we plan to host a central feed that contains (or points to) NuGet packages. Package authors will be able to create an account and start adding packages to the feed. The NuGet client tools will know about this feed by default.
  3. No central approval process for adding packages. When you upload a package to the NuGet Package Gallery (which doesn’t exist yet), you won’t have to wait around for days or weeks waiting for someone to review it and approve it. Instead, we’ll rely on the community to moderate and police itself when it comes to the feed. This is in the spirit of how CodePlex.com and RubyGems.org work.
  4. Anyone can host a feed. While we will host a central feed, we wanted to make sure that anyone who wants to can also host a feed. I would imagine that some companies might want to host an internal feed of approved open source libraries, for example. Or you may want to host a feed containing your curated list of the best open source libraries. Who knows! The important part is that the NuGet tools are not hard-coded to a single feed but support pointing them to multiple feeds.
  5. Command Line and GUI based user interfaces. It was important to us to support the productivity of a command line based console interface. Thus NuGet ships with the PowerShell based Package Manager Console which I believe will appeal to power users. Likewise, NuGet also includes an easy to use GUI dialog for adding packages.

NuGet’s Primary Goal

In my mind, the primary goal of NuGet is to help foster a vibrant open source community on the .NET platform by providing a means for .NET developers to easily share and make use of open source libraries.

As an open source developer myself, this goal is something that is near and dear to my heart. It also reflects the evolution of open source in DevDiv (the division I work in) as this is a product that will ship with other Microsoft products, but also accepts contributions. Given the primary goal that I stated, it only makes sense that NuGet itself would be released as a truly open source product.

There’s one feature in particular I want to call out that’s particularly helpful to me as an open source developer. I run an open source blog engine called Subtext that makes use of around ten to fifteen other open source libraries. Before every release, I go through the painful process of looking at each of these libraries looking for new updates and incorporating them into our codebase.

With NuGet, this is one simple command: List-Package –updates. The dialog also displays which packages have updates available. Nice!

And keep in mind, while the focus is on open source, NuGet works just fine with any kind of package. So you can create a network share at work, put all your internal packages in there, and tell your co-workers to point NuGet to that directory. No need to set up a NuGet server.

Get Involved!

So in the fashion of all true open source projects, this is the part where I beg for your help. ;)

It is still early in the development cycle for NuGet. For example, the Add Package Dialog is really just a prototype intended to be rewritten from scratch. We kept it in the codebase so people can try out the user interface workflow and provide feedback.

We have yet to release our first official preview (though it’s coming soon). What we have today is closer in spirit to a nightly build (we’re working on getting a Continuous Integration (CI) server in place).

So go over to the NuGet website on CodePlex and check out our guide to contributing to NuGet. I’ve been working hard to try and get documentation in place, but I could sure use some help.

With your help, I hope that NuGet becomes a wildly successful example of how building products in collaboration with the open source community benefits our business and the community.

What others have said

Requesting Gravatar... Rob White Oct 06, 2010 12:34 AM
# re: Introducing NuPack Package Manager
The thing that maybe I'm just not seeing is; where are the actual assembly files put, do they go into the GAC, do they end up in a folder related to your project somehow? Essentially what I'm wondering is, how will this work with a build server? If I add a package and write some code against that package, when I check my code in, will the build server need to fetch those packages as well? I guess the same question applies to deployment senarios.
Requesting Gravatar... Ian Cooper Oct 06, 2010 12:35 AM
# re: Introducing NuPack Package Manager
You may also want to use OpenWrap as an alternative to using NuPack: serialseb.blogspot.com/...
Requesting Gravatar... Will Shaver Oct 06, 2010 12:43 AM
# re: Introducing NuPack Package Manager
Congrats on the NuPack and MVC Releases. In your "guiding principles" I found "works against your source code" to be confusing. You probably want "works with your source code" or "on" or any number of other words. I first read that as "works antagonistically with your source code" ...

Then again, I never was too bright.
Requesting Gravatar... Philip Oct 06, 2010 12:53 AM
# re: Introducing NuPack Package Manager
It would be quite nice if this were not "included" with MVC3 at release - It certainly has lots of usage outside it, and I hate having to install something to get the benefits of an unrelated feature.
Requesting Gravatar... haacked Oct 06, 2010 1:16 AM
# re: Introducing NuPack Package Manager
@Rob, it puts the assemblies in a subfolder of the "packages" folder which is place inside your solution folder. So if you add your entire solution folder to source control, you're all set.

@Will Thanks! I corrected it.

@Philip you don't have to install MVC 3 to get it. Just grab the VSIX from http://nupack.codeplex.com/
Requesting Gravatar... Jared Roberts Oct 06, 2010 1:43 AM
# re: Introducing NuPack Package Manager
Is there something I am doing wrong?

PM> List-Package
Exception calling "GetPackageManager" with "1" argument(s): "The path is not of a legal form."
At D:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\CodePlex Foundation\NuPack Tools\0.1\Scripts\nupack
.ps1:524 char:80
+ $packageManager = [NuPack.VisualStudio.VsPackageManager]::GetPackageManager <<<< ([object]$dte)
+ CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : DotNetMethodException
Requesting Gravatar... Jared Roberts Oct 06, 2010 1:46 AM
# re: Introducing NuPack Package Manager
nevermind, it appears you have to be in a project or solution. I was in a website.
Requesting Gravatar... Chris Oct 06, 2010 1:59 AM
# re: Introducing NuPack Package Manager
Getting this error when I open up the Package Manager Window:


The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\WINDOWS\system32\WindowsPowerShell\v1.0\types.ps1xml(2943) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: Cannot convert the "Microsoft.PowerShell.Commands.SecurityDescriptorCommandsBase" value of type "System.String" to type "System.Type".
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\WINDOWS\system32\WindowsPowerShell\v1.0\types.ps1xml(2950) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: Cannot convert the "Microsoft.PowerShell.Commands.SecurityDescriptorCommandsBase" value of type "System.String" to type "System.Type".
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\WINDOWS\system32\WindowsPowerShell\v1.0\types.ps1xml(2957) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: Cannot convert the "Microsoft.PowerShell.Commands.SecurityDescriptorCommandsBase" value of type "System.String" to type "System.Type".
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\WINDOWS\system32\WindowsPowerShell\v1.0\types.ps1xml(2964) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: Cannot convert the "Microsoft.PowerShell.Commands.SecurityDescriptorCommandsBase" value of type "System.String" to type "System.Type".
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\WINDOWS\system32\WindowsPowerShell\v1.0\types.ps1xml(2971) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: Cannot convert the "Microsoft.PowerShell.Commands.SecurityDescriptorCommandsBase" value of type "System.String" to type "System.Type".
System.Management.Automation.ActionPreferenceStopException: Command execution stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Unable to find type [NuPackConsole.Host.PowerShell.Implementation.PSTypeWrapper]: make sure that the assembly containing this type is loaded.
at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at System.Management.Automation.Runspaces.Pipeline.Invoke()
at NuPackConsole.Host.PowerShell.Implementation.PowerShellHost.Invoke(String command, Object input, Boolean outputResults)
at NuPackConsole.Host.PowerShell.Implementation.PowerShellHost.LoadStartupScripts()
at NuPackConsole.Host.PowerShell.Implementation.PowerShellHost.Initialize()
at NuPackConsole.Host.PowerShell.Implementation.PowerShellHostProvider.<>c__DisplayClass2.<CreateHost>b__1(Object sender, EventArgs e)
at NuPackConsole.CommonExtensionMethods.Raise(EventHandler ev, Object sender, EventArgs e)
at NuPackConsole.Implementation.Console.ConsoleDispatcher.Start()
at NuPackConsole.Implementation.PowerConsoleToolWindow.MoveFocus(FrameworkElement consolePane)
Requesting Gravatar... Paul Cox Oct 06, 2010 2:02 AM
# re: Introducing NuPack Package Manager
Does NuPack have any mechanisms for getting the bleeding edge version of a product, e.g. NHibernate 3?
Requesting Gravatar... Chris Oct 06, 2010 2:07 AM
# re: Introducing NuPack Package Manager
Was able to add a package after closing and restarting VS2010, but I don't see any changes to the web.config under httpModules section.
Requesting Gravatar... Alec Whittington Oct 06, 2010 4:04 AM
# re: Introducing NuPack Package Manager
Congrats on the NuPack release as well as the MVC 3 Beta release.

NuPack is long over due for the .NET community.
Requesting Gravatar... Jonas Oct 06, 2010 4:08 AM
# re: Introducing NuPack Package Manager
Phil, why powershell? I would love for it to have a user interface using powershell behind the scenes and have the ability to use either.
Requesting Gravatar... Gregg Oct 06, 2010 5:35 AM
# re: Introducing NuPack Package Manager
@Jonas: Installing the extension also adds an "Add Package Reference..." option in VS2010. (Phil mentions it in passing above but doesn't really explain much about it. It's there, though.) You can use either the PowerShell approach or the GUI-style depending on your mood.
Requesting Gravatar... Keith J. Farmer Oct 06, 2010 5:44 AM
# re: Introducing NuPack Package Manager
Excellent!

Need to add NuPack to the VS Extension Manager feed. :)

By any chance does NuPack currently add support for adding packages to the machine itself, outside the context of VS or the like, or could it be extended to do so? I'm thinking akin to WebPI or Windows Update.

Does it have update- or rename-package facilities? Perhaps optionally alasing a package (eg, to deal with new Magic Unicorn drops that require some work to transition)?
Requesting Gravatar... Eric Falsken Oct 06, 2010 6:40 AM
# re: Introducing NuPack Package Manager
How do I contribute a package to the library?
Requesting Gravatar... haacked Oct 06, 2010 8:12 AM
# re: Introducing NuPack Package Manager
@Chris Upgrade your reflector to 6.5. See the FAQ and list of Known Issues.

@Paul if someone adds a package for it, sure. We don't yet have a way to distinguish between stable and pre-release yet though.

@Jonas PowerShell is a thin wrapper over our core API. We *also* have a GUI. Check out this 1.5 minute intro video!

@Keith Yes, we plan to add it to the VS Extension Manager. No plans to support adding packages outside of a VS solution.

@Eric the current feed is a temporary measure. Read the FAQ and it'll walk you through how to get a package there.
Requesting Gravatar... John Moshakis Oct 06, 2010 9:19 AM
# re: Introducing NuPack Package Manager
Is the command line interface tied to specific languages ?

Its just that the vsix install doesn't seem to recognize the visual studio shell as a valid application.
Requesting Gravatar... Chris Oct 06, 2010 9:45 AM
# re: Introducing NuPack Package Manager
Does it put the packages folder in the same directory as the sln file regardless of where that is, or next to the project files?

What if I don't want them in 'packagee'? Can you alter the default location, like a folder directory above the solution directory (think a libs folder shared by many related project directories.
Requesting Gravatar... Adam Oct 06, 2010 8:12 PM
# re: Introducing NuPack Package Manager
it would be great if we could configure where the packages are stored. so change the 'packages' folder to say 'libs' or whatever our organisation prefers. otherwise, great step forward guys!
Requesting Gravatar... Christopher Painter Oct 07, 2010 1:17 AM
# re: Introducing NuPack Package Manager
Here's my two concerns:

1) How does it handle the build environment? Does this assume you'll check the package files into source control so the build will pull it down as part of the workspace? Our current build proccesses avoid this intentionally.

2) While it's great to get some cool widget into the hands of a developer, I'm concerned it's an abstraction that many people will use to turn off their brain when it comes to dependency / integration analysis. Just issue the get package command, rebuild the solution and publish. Easy, right?

Still, if those concerns aren't a worry, it does seem like a really slick tool.
Requesting Gravatar... Matt Mills Oct 07, 2010 3:16 AM
# re: Introducing NuPack Package Manager
Does the feed allow contributors to tag upgrades as breaking or otherwise incompatible with previous versions?
Requesting Gravatar... Robert Oct 07, 2010 3:40 AM
# re: Introducing NuPack Package Manager
In all the demos and videos, the person is installing elmah, but elmah isn't listed as an available package when I run NuPack. It also doesn't install from the command line (I get an error that says elmah can't be found).

What gives?
Requesting Gravatar... Josh Oct 07, 2010 3:42 AM
# re: Introducing NuPack Package Manager
Anyone know where to get Ninject MVC2 using nupack?
Requesting Gravatar... Steve Oct 09, 2010 8:19 AM
# re: Introducing NuPack Package Manager
I grabbed MvcTurbine and Windsor - and it was fine, except MvcTurbine uses a prior version of the Windsor included.

Anything to be done for this - because these types of mismatches are the real problem with OSS imo - not the delivery system (although a delivery system is nice to have).

Requesting Gravatar... Esteban Oct 12, 2010 2:56 AM
# re: Introducing NuPack Package Manager
@Robert Same here. I installed this just for elmah and it's not even in the package list.

Do I need to download a list from somewhere else?
Requesting Gravatar... George Birbilis Nov 09, 2010 1:56 AM
# re: Introducing NuGet Package Manager
Nice images at 2nd part of tell the story of NuGet power in a few words:
weblogs.asp.net/...
Requesting Gravatar... Stoyan Dec 27, 2010 4:26 AM
# re: Introducing NuGet Package Manager
I wasn't able to install NuPack.Server on IIS 7 on a Windows 2008 box - web deployment failed w/ various errors, I tried everything and the kitchen sink and couldn't make this work. Is there *anyone* who was able to deploy the server to provide a local repository at his company? TIA, Stoyan

What do you have to say?

(will show your gravatar)
Please add 5 and 8 and type the answer here: