Scott Hanselman

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

March 09, 2012 Comment on this post [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
Hosting By
Hosted in an Azure App Service
March 10, 2012 0:11
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.
Bil
March 10, 2012 0:16
Brilliant, I didn't knew that, so MacGyver saved the day after all.
March 10, 2012 0:22
Bil - Yes, I assumed that was obvious. ;)
March 10, 2012 0:24
"...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
March 10, 2012 0:39
Perhaps I'm missing something, but how is it a cache if it's not checked automatically?
March 10, 2012 0:59
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/
March 10, 2012 1:11
great tip !
March 10, 2012 1:33
"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?
March 10, 2012 2:52
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.
March 10, 2012 3:14
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/
March 10, 2012 3:43
Great demo, Scott. I think the nuGet need to have fallback plan.
March 10, 2012 4:59
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.
March 10, 2012 6:18
On a plane? But I have 3.1 Mbps on my plane... ;-)
March 10, 2012 22:51
Wow!!! That was awesome!!!
March 11, 2012 22:21
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.
March 12, 2012 1:27
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
March 12, 2012 2:09
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
March 12, 2012 12:44
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?
March 12, 2012 14:02
Here’s the path %localappdata%\NuGet\Cache
March 12, 2012 19:37
Great tip! And nice recovery. Duly impressed watching you recover from this without skipping a beat! Great keynote and great conference!

Thanks
March 13, 2012 8:16
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 :)
March 13, 2012 9:33
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.
March 15, 2012 13:01
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
March 15, 2012 17:28
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? :)
March 16, 2012 3:54
Mark - No, I don't think so. The toolbox with focus turns blue.
March 20, 2012 10:35
I believe the best path to use would be %LOCALAPPDATA%\nuget\cache
March 26, 2012 14:49
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? :)
July 24, 2012 5:54
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'.
May 06, 2013 12:36
Great Stuff!

Comments are closed.

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