Scott Hanselman

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

June 27, 2012 Comment on this post [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
Hosting By
Hosted in an Azure App Service
June 27, 2012 5:10
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.
June 27, 2012 5:16
Uninstalling the extension and reinstalling it *from VS* extension manager did the trick.
June 27, 2012 5:18
i think AspNetWebApi.SelfHost is duplicated in the list
June 27, 2012 5:36
Bertrand - I added info on that one. That's a VS bug for which there is a hotfix http://bit.ly/vsixcertfix.
June 27, 2012 8:55
Yes, my bad for not making the connection.
June 27, 2012 9:58
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).
June 27, 2012 11:39
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.
June 27, 2012 11:41
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.
June 27, 2012 13:03
The Hotfix didn´t work for me. :(
June 27, 2012 16:08
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.
June 27, 2012 17:43
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.
June 27, 2012 19:20
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!
June 27, 2012 21:51
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
June 28, 2012 1:05
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.)?
June 28, 2012 1:09
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.
June 28, 2012 2:37
Doesn't install for VS 2010 Professional
June 28, 2012 18:13
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.
June 28, 2012 18:55
Doesn't install (VS2010 Premium)
No message, no error, just the hourglass for a few seconds
Rik
June 28, 2012 19:12
@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.
June 29, 2012 11:06
Yes, yes, put pressure on Mads. We do wan't to search nuget aswell!
June 29, 2012 11:49
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.

Rik
June 30, 2012 5:53
"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?
June 30, 2012 6:05
Paul - VS is a 32bit only app so that's for all systems.
June 30, 2012 13:53
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.
July 02, 2012 15:30
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
July 04, 2012 1:13
"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 :)
August 10, 2012 7:49
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.
August 15, 2012 15:30
Yes - Mads - pull your finger out.... ;o)
August 15, 2012 22:55
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???
December 21, 2012 23:26
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.

Comments are closed.

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