NuGet 2.0 (.NET Package Manager) released - GO UPGRADE NOW and here's why
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.
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
- Close all instances of VS
- Examine the contents of HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\ExtensionManager\PendingDeletions
- Delete the folders listed for each entry
- 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.
And you'll get nice Intellisense for packages.
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:
<dependency id="RouteMagic" version="1.1.0" />
<dependency id="jQuery" />
<dependency id="WebActivator" />
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
targetFrameworkattribute 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.
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. ;)
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...
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|
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.
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.
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).
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.
The Namespace mapping list is gold. Now I know what to watch out for when 'upgrading' my MVC4 Beta samples to MVC4 RC.
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.
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.)?
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.
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.
No message, no error, just the hourglass for a few seconds
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.
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.
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?
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
Thanks Scott! We love you guys even more now :)
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.
How do I get the list back???
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.