Scott Hanselman

How to access NuGet when 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 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 (the server). I know that the team is aiming for "5 nines" availability with the 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, 09 March 2012 20:11:26 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 to your hard drive.
Friday, 09 March 2012 20:16:17 UTC
Brilliant, I didn't knew that, so MacGyver saved the day after all.
Friday, 09 March 2012 20:22:10 UTC
Bil - Yes, I assumed that was obvious. ;)
Friday, 09 March 2012 20:24:28 UTC
" 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!

Friday, 09 March 2012 20:39:48 UTC
Perhaps I'm missing something, but how is it a cache if it's not checked automatically?
Friday, 09 March 2012 20:59:15 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:
Friday, 09 March 2012 21:11:34 UTC
great tip !
Friday, 09 March 2012 21:33:12 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.

" 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, 09 March 2012 22:52:49 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, 09 March 2012 23:14:01 UTC
Here's how to do it with the NuGet.exe command line tool:
Friday, 09 March 2012 23:43:20 UTC
Great demo, Scott. I think the nuGet need to have fallback plan.
Saturday, 10 March 2012 00:59:34 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, 10 March 2012 02:18:41 UTC
On a plane? But I have 3.1 Mbps on my plane... ;-)
Saturday, 10 March 2012 18:51:11 UTC
Wow!!! That was awesome!!!
Sunday, 11 March 2012 18:21:18 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, 11 March 2012 21:27:11 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 Ruiz
Sunday, 11 March 2012 22:09:21 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, 12 March 2012 08:44:47 UTC
I didn't know Nuget automatically creates a local package cache. I blogged about creating your own local repository with Powershell over here: 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, 12 March 2012 10:02:18 UTC
Here’s the path %localappdata%\NuGet\Cache
Monday, 12 March 2012 15:37:17 UTC
Great tip! And nice recovery. Duly impressed watching you recover from this without skipping a beat! Great keynote and great conference!

Tuesday, 13 March 2012 04:16:31 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, 13 March 2012 05:33:31 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.
Thursday, 15 March 2012 09:01:34 UTC
So what was the crowd reaction like when you got it fixed? Please fill this form out as appropriate:
Thursday, 15 March 2012 13:28:11 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, 15 March 2012 23:54:03 UTC
Mark - No, I don't think so. The toolbox with focus turns blue.
Tuesday, 20 March 2012 06:35:16 UTC
I believe the best path to use would be %LOCALAPPDATA%\nuget\cache
Monday, 26 March 2012 10:49:23 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, 24 July 2012 01:54:18 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, 06 May 2013 08:36:30 UTC
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.