Scott Hanselman

How to access NuGet when NuGet.org is down (or you're on a plane)

March 9, '12 Comments [29] Posted in NuGet | Open Source
Sponsored By

I was in Dallas today speaking at the Dallas Day of .NET. During my keynote presentation - it included lots of NuGet demos - and for some reason the NuGet.org site was down at that exact moment. I ended up coming up in the middle somewhere. I'm not in Redmond so I don't know what happened and I won't speak for the team. However, my initial reaction was "I'm screwed" and the crowd was interested in how I was going to continue. We all depend on NuGet (the system) and NuGet.org (the server). I know that the team is aiming for "5 nines" availability with the NuGet.org site and that it runs in Azure now. I assume they'll put an explanation of the issue up on the site soon.

Regardless, you might think I was stuck. Well, remember that NuGet caches the packages it downloads on your local hard drive. My cache was located at C:\Users\scottha\AppData\Local\NuGet\Cache.

The Local NuGet Package Cache

You can add that cache folder as a NuGet Source by going to Options | Package Manager | Package Sources. You can see I added it in my dialog below.

The NuGet Package Source Options dialog

Then later, when I'm using NuGet offline I can select my cache if need be. Again, I should never need to, but you get the idea:

The NuGet Cache selected as an option in the Package Manager Console 

If you're concerned about external dependencies on a company-wide scale, you might want to have a network share (perhaps on a shared builder server) within your organization that contains the NuGet packages that you rely on. This is a useful thing if you are in a low-bandwidth situation as an organization.

If you think a feature that makes offline a more formal state is useful, please go vote up this "offline" issue on NuGet's CodePlex site and join the conversation with ideas on how you think "NuGet on an airplane" or "low/no bandwidth NuGet" should work. For example, should it automatically fall back? Should there be a timeout? Should there by an -offline explicit option? Should the existing Offline Cache be added automatically?

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
Friday, March 09, 2012 8:11:26 PM UTC
Of course you have to had download the package at least once for this to work. Just in case someone thinks magical elves are secretly copying the entire contents of nuget.org to your hard drive.
Friday, March 09, 2012 8:16:17 PM UTC
Brilliant, I didn't knew that, so MacGyver saved the day after all.
Friday, March 09, 2012 8:22:10 PM UTC
Bil - Yes, I assumed that was obvious. ;)
Friday, March 09, 2012 8:24:28 PM UTC
"...my initial reaction was \"I'm screwed\" and the crowd was interested in how I was going to continue. . . . remember that NuGet caches the packages it downloads on your local hard drive. My cache was located at C:\Users\scottha\AppData\Local\NuGet\Cache."

What a great move that was! Nerds survive on tips and hidden details in common technologies!

+1
Friday, March 09, 2012 8:39:48 PM UTC
Perhaps I'm missing something, but how is it a cache if it's not checked automatically?
Friday, March 09, 2012 8:59:15 PM UTC
It was a really slick recovery. I was like ZOMG what's he going to do now. I do want you to know that I had your back if it came down to it: http://nooooooooooooooo.com/
Friday, March 09, 2012 9:11:34 PM UTC
great tip !
Friday, March 09, 2012 9:33:12 PM UTC
"I was in Dallas today speaking at the Dallas Day of .NET."

How did I not know about this?? I live in Las Colinas, I definitely would have been there.

"...how is it a cache if it's not checked automatically?"

I'm with Derek; why is Nuget caching the packages locally in the first place if the intent is not to be able to install them from there without needing access to the external server? Is it just there as a stop gap because they knew people would get in this situation, but they haven't had time to implement a better solution?
Friday, March 09, 2012 10:52:49 PM UTC
David - crazy! I stayed at the Aloft in Las Colinas and ate at the Chipotle there. ;) Yes, I agree that the cache should be a fallback. I mentioned in a year ago and now I'm pushing the issue with the work item I reference in the blog post.
Scott Hanselman
Friday, March 09, 2012 11:14:01 PM UTC
Here's how to do it with the NuGet.exe command line tool: http://lostechies.com/derekgreer/2012/03/09/dependency-management-in-net-offline-dependencies-with-nuget-command-line-tool/
Friday, March 09, 2012 11:43:20 PM UTC
Great demo, Scott. I think the nuGet need to have fallback plan.
Saturday, March 10, 2012 12:59:34 AM UTC
Scott, I was thoroughly impressed with both the presentation and the amazing recovery--not to mention the super cool head under pressure. Thanks for coming down--we appreciated having you here.
Saturday, March 10, 2012 2:18:41 AM UTC
On a plane? But I have 3.1 Mbps on my plane... ;-)
Saturday, March 10, 2012 6:51:11 PM UTC
Wow!!! That was awesome!!!
Sunday, March 11, 2012 6:21:18 PM UTC
I was there for this keynote, and I was also very impressed at how smoothly you recovered from that. It was well worth the drive to Dallas to see you in action.
Bryan Wilson
Sunday, March 11, 2012 9:27:11 PM UTC
Hi, Scott
Are you using VS11 as your main IDE?

/* Off Topic Comment
When will you come to Buenos Aires for an event organized by Microsoft?
Last year in a break I I talked with Phil Haack personally.
I'd like to meet and chat with you.
*/

Greetings from Argentina.
Francisco
Francisco Ruiz
Sunday, March 11, 2012 10:09:21 PM UTC
I was there when hansleman pull this off impromptu in front of a few hundred people.

Handled it like a boss.


Also the Keynote was great! I had so much fun at the Day of .NET
Monday, March 12, 2012 8:44:47 AM UTC
I didn't know Nuget automatically creates a local package cache. I blogged about creating your own local repository with Powershell over here: http://joshilewis.wordpress.com/2012/01/13/creating-a-local-nuget-cacherepository/ I have since also started using Nuget.Server with this repository.

One note: I recently re-installed Windows on my PC. This obviously cleared my Users folder, and I lost the cached packages. However because my own custom repository is located on a different partition, I didn't lose those packages. Is there any way to change the location of the automatic cache?
Monday, March 12, 2012 10:02:18 AM UTC
Here’s the path %localappdata%\NuGet\Cache
Matt
Monday, March 12, 2012 3:37:17 PM UTC
Great tip! And nice recovery. Duly impressed watching you recover from this without skipping a beat! Great keynote and great conference!

Thanks
Tuesday, March 13, 2012 4:16:31 AM UTC
In similar situations, I have seen so many people saying "I don't know what's gone wrong and blah blah..."
But you were spot on as I expected you to be.

And you proved me right...Great! Liked it :)
Tuesday, March 13, 2012 5:33:31 AM UTC
When a computer does something twice that only needs to be done once: deity.kill(1, AnimalType.Feline).

In this case, as well as the case where I have to update 6 nuget packages after file | new | mvc 4 app to get the current versions of the jQuery, ko, etc. this is pretty silly. Hopefully this will be addressed in VS11 by RTM
i.e. I would like to see this update occur and take effect on all future new projects.
anon
Thursday, March 15, 2012 9:01:34 AM UTC
So what was the crowd reaction like when you got it fixed? Please fill this form out as appropriate:

http://knowyourmeme.com/memes/fck-yea
Thursday, March 15, 2012 1:28:11 PM UTC
Interesting: the Package Manager Console title text in your screen-shot is in blue. Is that an option somewhere in Beta, or are you using a later build where some color* has been allowed back in? :)
Thursday, March 15, 2012 11:54:03 PM UTC
Mark - No, I don't think so. The toolbox with focus turns blue.
Tuesday, March 20, 2012 6:35:16 AM UTC
I believe the best path to use would be %LOCALAPPDATA%\nuget\cache
Monday, March 26, 2012 10:49:23 AM UTC
Although this is a great tip that apparently saved the day, this should never have happened, specially with a professional speaker like you.

Don't get me wrong (I admire you a lot), but one of the preparation steps for any presentation that is going to use NuGet is to have all the packages you will need during the demos on a local folder that you can use as a Package Source.

I'm sure you already do that (probably that Dropbox folder) and just forgot to mention in the post.

It just doesn't feel right to imagine that THE ScottHa was saved by NuGet Cache instead of his own local cache that was previously thought about and planned before leaving home, you know? :)
Tuesday, July 24, 2012 1:54:18 AM UTC
I accidentally clicked the "Clear Package Cache" button in the settings and it wiped out my cache file. NuGet still thinks a bunch of packages are installed, but somehow all the references in my project got removed. How can I re-install the NuGet packages and the refrences? The package manager thinks the packages are installed and won't let me install them again.

I think I really am 'screwed'.
Phil Deibel
Monday, May 06, 2013 8:36:30 AM UTC
Great Stuff!
Pravir
Comments are closed.

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