Scott Hanselman

NuGet 2.0 (.NET Package Manager) released - GO UPGRADE NOW and here's why

June 27, '12 Comments [30] Posted in NuGet
Sponsored By

Before we get started, take a second and head over to http://nuget.org and click Install NuGet. Actually, just do it from here. I'll wait.

Install NuGet

It's a 2.5 meg VSIX file and will take just a minute to install. It'll work on Visual Studio 2010 SP1 as well as Visual Studio 2012 RC. If you have them all installed at the same time, NuGet will prompt you to install in all of them if you like.

Weird Issues you might hit

If you are an early adopter and are testing Visual Studio 2012 RC, first, thanks. If you see a dialog box on VS2012RC that says "Configuring Extensions" and seems to sit forever, we have a bug that was fixed for RTM that is starting to surface more frequently with the recent NuGet update. The bug is a race condition that occurs intermittently when a user updates his extensions in the RC release.

Workaround for hung at "Configuring Extensions" on Visual Studio 2012 RC

  1. Close all instances of VS
  2. Examine the contents of HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\ExtensionManager\PendingDeletions
  3. Delete the folders listed for each entry
  4. Delete HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\ExtensionManager\PendingDeletions

99.9% of upgrades or installs will work just fine. If you see any other issues, run Visual Studio once as Administrator, go to Tools | Extensions Manager and uninstall NuGet, then install again.

The most common installation issue is a certificate mismatch with Visual Studio 2010 SP1. Unfortunately this one isn't NuGet's bug but you can get a Visual Studio hotfix here to fix it once and for all - http://bit.ly/vsixcertfix This should be in Windows Update one day, I hope. Either installing that hotfix or uninstalling/reinstalling as admin will fix the issue for NuGet.

Fixed Issues and New Features

Here's a query to the complete list of the 80 issues that were fixed in Version 2.0 of NuGet. NuGet has seen over 14 MILLION package downloads and there are over 6,000 unique packages in the gallery. You can see the updated stats anytime at http://stats.nuget.org.

The best fix, and the one I have personally been pushing the most on was this Issue: NuGet PowerShell Tab Completion is SLOW over a slow connection. If you are on a slow collection (I'm talking to you, New Zealand) or just appreciate speed, this is reason enough to upgrade NuGet.

Before, typing Install-Package jQuery.[TAB] would cause an HTTP call to go to OData that would return more data than was required. I'm always pushing for folks who are not in the US on 35 megabit connections. Often because I'm over there to, sucking data through 3G.

With NuGet 2.0 typing Install-Package JQuery.[TAB] will make a quick JSON call like this:

GET /api/v2/package-ids?partialId=jQuery. HTTP/1.0

Which will return, in this case, 603 bytes of JSON, as it should. It's fast.

["jQuery.Ajax.Unobtrusive", 
"jQuery.ba-throttle-debounce",
...,
"jQuery.LiveQuery",
"jQuery.MaskedInput",
"jQuery.Meow"]

And you'll get nice Intellisense for packages.

Intellisense in NuGet 2.0

New Features

Not only is NuGet 2.0 faster, but there's some new features like dependency grouping by target framework. You can vary your dependences such that one package can service .NET 2 and .NET 4 but each target framework requires a different bunch of packages. Here's a example:

<dependencies> 
<group>
<dependency id="RouteMagic" version="1.1.0" />
</group>

<group targetFramework="net40">
<dependency id="jQuery" />
<dependency id="WebActivator" />
</group>

<group targetFramework="sl30">
</group>
</dependencies>

From the docs:

Note that a group can contain zero dependencies. In the example above, if the package is installed into a project that targets Silverlight 3.0 or later, no dependencies will be installed. If the package is installed into a project that targets .NET 4.0 or later, two dependencies, jQuery and WebActivator, will be installed. If the package is installed into a project that targets an early version of these 2 frameworks, or any other framework, RouteMagic 1.1.0 will be installed. There is no inheritance between groups. If a project's target framework matches the targetFramework attribute of a group, only the dependencies within that group will be installed.

Even better, you can now group your PowerShell scripts as well as your content files by target framework. Specific scripts can run depending on your versions and specific content files can be included. This uses the same directory hierarchy you are already using for dependencies only now it works for /content and /tools as well.

Turn on "Allow NuGet to download missing packages during build" to make your life easier

Finally, do be aware that you have to explicitly give the OK to "restore packages" at least once, in order to enable NuGet to fetch a bunch of dependencies for you. Often you'll get a large project that you want to compile and perhaps that project includes a packages.config but not the packages itself (you don't want check your binary packages into source control, for example) so NuGet will restore missing packages when it's time to build. You only need to do this once to satisfy the lawyers.

Turn on Package Consent in Package Manager | General

Sneak Peak of Feature UI Features (thanks Mads!)

You know the new Ctrl-Q "search all commands" feature in Visual Studio 2012? I've seen a daily build of a possible improvement to NuGet on Mads' computer that not only searched Visual Studio local commands, but also the Visual Studio Gallery AND NuGet Packages. Leave a comment if you like this feature and I'll put pressure on Mads. Or, you will. ;)

jQuery searched for in the main Visual Studio CTRL-Q Quick search box

The Great Package Rename

We've changed the names of a BUNCH of packages (and forwarded the old names) so there's a little more logic to the Microsoft ones, at least. For example, here's the autocomplete for Microsoft.AspNet...

Microsoft.AspNet. intellisense

With this RC release, all of the NuGet packages involved in the ASP.NET products were renamed. Internally we called it the "Big Package Rename of 2012." Here is a mapping of old package names to new package names. In this list, the old names refer to prior versions of the products, including the Beta releases that shipped with VS 11 Beta.

OLD PACKAGE NEW PACKAGE
AspNetMvc Microsoft.AspNet.Mvc
AspNetRazor.Core Microsoft.AspNet.Razor
AspNetWebApi Microsoft.AspNet.WebApi
AspNetWebApi.Core Microsoft.AspNet.WebApi.Core
AspNetWebApi.SelfHost Microsoft.AspNet.WebApi.SelfHost
AspNetWebPages.Core Microsoft.AspNet.WebPages
AspNetWebPages Microsoft.AspNet.WebPages.Administration
jQuery.Ajax.Unobtrusive Microsoft.jQuery.Unobtrusive.Ajax
jQuery.Validation.Unobtrusive Microsoft.jQuery.Unobtrusive.Validation
Microsoft.Web.Optimization Microsoft.AspNet.Web.Optimization
SqlServerCompact Microsoft.SqlServer.Compact
System.Net.Http Microsoft.Net.Http
System.Net.Http.Formatting Microsoft.AspNet.WebApi.Client
System.Web.Providers Microsoft.AspNet.Providers
System.Web.Providers.Core Microsoft.AspNet.Providers.Core
System.Web.Providers.LocalDb Microsoft.AspNet.Providers.LocalDb
System.Web.Providers.SqlCE Microsoft.AspNet.Providers.SqlCE

We are hoping the other companies (and others inside of Microsoft) will follow the same standard naming structure

Hosting your own Feeds (and other NuGet sightings in the community)

If you haven't noticed there's a bunch of cool NuGet-specific sites and applications showing up in the wild.

  • MyGet - Create and host your own NuGet feed in the cloud. Host for your company, add security, privileges and more. Great for companies as well as automated build systems.
  • SymbolSource - "SymbolSource is an integrated solution for hosting and browsing code releases - specifically, but not only, NuGet and OpenWrap packages. It's true power, however, comes from implementing the srcsrv protocol, which allows Visual Studio and other compatible software to download on-demand symbol (PDB) and source files from SymbolSource."
  • TeamCity - TeamCity 7 supports packing and publishing of Nuget packages via a NuGet plugin (thanks Eugene Petrenko!) that is now installed by default!
  • Sonatype Nexus - Supports the Java Maven repository and now NuGet.
    • Allows the customer to have a local copy of the entire NuGet repository
    • Allow the customer to select which license types of software they support and only show them matching NuGet’s
    • Allow the customer to see that the NuGet’s they are consuming do not contain code copied from other projects
  • NuGet Server written in Java - Eugene created a small NuGet server that you can run under Linux and Java 1.6. It's all part of the larger TeamCity NuGet support and on GitHub as well as NuGet itself (inception!)
  • WebMatrix 2 - WebMatrix not only supports NuGet but it includes the gallery as a toolbar button and uses NuGet to install additional functionality like iPhone and iPad simulators!
  • NuGetFeed - Create a personalized feed of packages you care about and never miss another update!
  • ProGet is an NuGet repository for the enterprise, includes LDAP-based permissions and scoped feeds for multiple teams. Host private NuGet packages, as well as cache and filter other repositories. Free edition available.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web
Wednesday, June 27, 2012 1:10:25 AM UTC
Fail: The signature on the update version of 'NuGet Package Manager' does not match the signature on the installed version. Therefore, Extension Manager cannot install the update.
Wednesday, June 27, 2012 1:16:11 AM UTC
Uninstalling the extension and reinstalling it *from VS* extension manager did the trick.
Wednesday, June 27, 2012 1:18:25 AM UTC
i think AspNetWebApi.SelfHost is duplicated in the list
Wednesday, June 27, 2012 1:36:56 AM UTC
Bertrand - I added info on that one. That's a VS bug for which there is a hotfix http://bit.ly/vsixcertfix.
Wednesday, June 27, 2012 4:55:44 AM UTC
Yes, my bad for not making the connection.
Wednesday, June 27, 2012 5:58:18 AM UTC
Excellent write-up!

One word of caution though: people using NuGet package restore on build servers *without* internet connectivity are going to face issues when enabling package restore on new projects.

Package restore is now using a Bootstrapper (also called nuget.exe) which downloads and auto-updates the Commandline (nuget.exe) during restore (and not before!). This requires internet access. More details here: http://nuget.codeplex.com/workitem/2390

Current workaround is to replace the nuget.exe (found in NuGet.Bootstrapper) that package restore added by the actual NuGet commandline (found in NuGet.CommandLine).
Wednesday, June 27, 2012 7:39:24 AM UTC
Nuget can be incredibly frustrating. It took several minutes deleting references from .csproj files before reporting a version issue and not fully rolling back:


Successfully installed 'Microsoft.SqlServer.Compact 4.0.8854.2'.
Successfully uninstalled 'Microsoft.SqlServer.Compact 4.0.8854.2'.
Install failed. Rolling back...
Could not install package 'Microsoft.SqlServer.Compact 4.0.8854.2'. You are trying to install this package into a project that targets '.NETFramework,Version=v3.5', but the package does not contain any assembly references that are compatible with that framework. For more information, contact the package author.
RichB
Wednesday, June 27, 2012 7:41:25 AM UTC
Another sighting from the NuGet community: NuGetFeed.org. Add your favorite NuGet package to your feed and listen for updates on those packages in your RSS reader.
Wednesday, June 27, 2012 9:03:11 AM UTC
The Hotfix didn´t work for me. :(
Wednesday, June 27, 2012 12:08:33 PM UTC
Nuget 1.8 has been acting strange (specially with MVC4 RC, VS2010 SP1). Package Restore seemed awfully confused, not sure if it had anything to do with the Namespace changes (ending in packages not getting restored/updated). Thanks for the writeup and the gotchas list, will test it out.

The Namespace mapping list is gold. Now I know what to watch out for when 'upgrading' my MVC4 Beta samples to MVC4 RC.

Regards,
Sumit.
Wednesday, June 27, 2012 1:43:54 PM UTC
Great post!
Just want to add. TeamCity is also able to work as NuGet feed server too.
So it includes the most of NuGet.Java.Server package inside.
Wednesday, June 27, 2012 3:20:55 PM UTC
Question - say we have the setting to Allow NuGet download of missing packages on a project that does not get updated very often. If years pass, and that project is still referencing an old NuGet package, and a new dev pulls it from SVN - what guarantee is there (if any) that old packages will be available for any length of time. Is there a time period where it's certain to be there, will it be there forever, or is there NO certainty there at all?

Thanks!
Wednesday, June 27, 2012 5:51:46 PM UTC
Does the restore feature replace Nuget Power Tools package restore?

http://blog.davidebbo.com/2011/08/easy-way-to-set-up-nuget-to-restore.html
Wednesday, June 27, 2012 9:05:18 PM UTC
The update looks excellent.

When hosting an internal feed (ex. restricted public packages and custom in-house packages), is there a way to ensure it keeps public packages up to date (ex. jQuery, Ninject, etc.)?
Wednesday, June 27, 2012 9:09:12 PM UTC
Oops, one more question.

Does Microsoft have any intention to integrate NuGet into the Team Foundation (TFS)?

It would be nice to host/manage a NuGet feed right from TFS, and checkin/out packages that way.
Wednesday, June 27, 2012 10:37:08 PM UTC
Doesn't install for VS 2010 Professional
Thursday, June 28, 2012 2:13:19 PM UTC
Excited about "restore package" being finally baked in.

Does this solve the problem of nuget versioning? We routinely run into the problem of someone new checking out source code and missing nuget libraries. When they go to download the library from nuget, they find that they downloaded a *newer* version than everyone else. (1.5 versus 1.4) So when they go to check in their code, everyone who updates their csproj file thereafter from source control will find that they're now missing that library even though it worked the day before. These people go to nuget to fix the missing reference and find that they download an even newer version! (1.6)

It's an endless loop. This is nuget dependency hell for us. We're probably doing it wrong, but nuget needs to allow us to choose which version to download and reference. Right now, it always gets latest, which doesn't work for very active libraries like JSON.NET.

We solved the problem by setting up our own package source.
jinushaun
Thursday, June 28, 2012 2:55:54 PM UTC
Doesn't install (VS2010 Premium)
No message, no error, just the hourglass for a few seconds
Thursday, June 28, 2012 3:12:36 PM UTC
@jinushaun - that is an issue for us as well. a decent workaround i've tried is to create a local feed and host the packages there. it's not much work and it prevents the extra versioning (so long as you don't update the package manually in your feed).

That said, I'd like to see how the restore works too. It would be nice if there were a flag on the XML node to mark if the package version was locked by default.
Friday, June 29, 2012 7:06:18 AM UTC
Yes, yes, put pressure on Mads. We do wan't to search nuget aswell!
Friday, June 29, 2012 7:49:37 AM UTC
Update:


The registry fix didn't work.

I was hesitant to uninstall the manager because of deadlines, but tried it anyway.

Uninstalling the manager worked, but the reinstall from the link on this blog still did nothing (where's that panic button).

Reinstalling it in the extention manager worked.

Saturday, June 30, 2012 1:53:20 AM UTC
"The most common installation issue is a certificate mismatch with Visual Studio 2010 SP1. Unfortunately this one isn't NuGet's bug but you can get a Visual Studio hotfix here to fix it once and for all - http://bit.ly/vsixcertfix This should be in Windows Update one day, I hope. Either installing that hotfix or uninstalling/reinstalling as admin will fix the issue for NuGet."

The KB article seems to imply that the fix is for x86 systems only and that there is none available for x64 - is this correct?
Saturday, June 30, 2012 2:05:52 AM UTC
Paul - VS is a 32bit only app so that's for all systems.
Scott Hanselman
Saturday, June 30, 2012 9:53:03 AM UTC
Thanks. I was confused by the KB download page hiding the patch when it detected I was running 64-bit Windows. I knew VS was 32-bit only, but was not sure whether it had installation quirks on a 64-bit system that made the "x86" update incompatible.
Monday, July 02, 2012 11:30:45 AM UTC
This is great news.
I also discovered extension which allows to copy and paste nuget packages between proejcts directly from solution explorer http://visualstudiogallery.msdn.microsoft.com/a83505c6-77b3-44a6-b53b-73d77cba84c8
Mathew Ronco
Tuesday, July 03, 2012 9:13:33 PM UTC
"If you are on a slow collection (I'm talking to you, New Zealand) or just appreciate speed, this is reason enough to upgrade NuGet"

Thanks Scott! We love you guys even more now :)
Barend
Friday, August 10, 2012 3:49:54 AM UTC
Why microsoft love money, hate developers? Half baked tools that are not used internally. Visual studio 2010 does not restore packages automatically with that extension enabled. Pretty much you have to run nuget command line manually on each of possibly many project folder's package.config; or alternatively have your rake/psake search each folder for packages.config. I'm really shocked because a minority of devs go as far as command line builds.

Oh man, I remember when I downloaded one of your c# projects. That was a resharper nightmare. Also, have you heard of this thing called dependency injection? My point is in the 7 years I have seen your blog posts, there is an imbalance of focusing on technology versus focusing on principles of building software right which is misleading to anyone junior/intermediate. I was mislead for sure.
John
Wednesday, August 15, 2012 11:30:06 AM UTC
Yes - Mads - pull your finger out.... ;o)
Wednesday, August 15, 2012 6:55:31 PM UTC
Sorry but in the public release of VS.net 2012 the package manager console's default project drop down is empty. Thus I can't run any migrations etc.

How do I get the list back???
Friday, December 21, 2012 7:26:45 PM UTC
It turns out that NuGet is not a real open source project.
Open source project allows you to modify the code, create your own version and install it on visual studio.
Lately, in my organization we had to create our modified version of NuGet but we discovered that MVC projects look for signed version of NuGet and would not open otherwise.
Now, you have the worst of both worlds - A product that is not offical Microsoft product and mandatory request for installing it without any modification.
Yaron
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.