Install NuGet Packages from the Cache


We all love NuGet, but like all cloud services, it is only available when the cloud is available. If you are on the proverbial airplane, you cannot install new packages or update existing packages. In my case, I ride the train back and forth from school twice a week, which is not a bad commute (30 minutes each way.) It is just long enough that sometimes I feel like getting out my laptop and doing some work. Just last week I started a new project on the train and I wanted to install Moq and write a test, and I ran into this snag.

Since I already had a local feed configured, this was easy enough to resolve. I navigated to a project that already had the latest version of Moq installed, grabbed the nupkg from that solution’s packages folder, and dropped it into my local feed. Problem solved. I know from experience that doing this would not cause me any problems. When the Moq team releases the next update to Moq, NuGet will see that version on line and start offering that version instead of the copy in the local feed.

Around the same time, Rory Becker suggested to the world (via Twitter – @RoryBecker) that NuGet should use its cache as a package source. I thought that configuring this manually by hand would be possible, but did not look into it. With the outage today, David Fowler (@davidfowl) suggested the idea. Now everyone knows. Oh well, that will teach me to sit on an idea.


How To

Setting up local package sources is easy. The official guide is located here on, but you can follow along here to setup this specific scenario.

First, start Visual Studio and open the Package Manager Options:


Click on the “Package Sources” item. You can enter whatever makes sense to you as the name. The name “Cache” makes sense to me. You cannot follow David’s tweet too literally because the options page will not accept the %LOCALAPPDATA% variable. If you try, the Package Manager Options will complain with the message: “The source specified is invalid. Please provide a valid source.”


Instead, paste the path “%LOCALAPPDATA%\NuGet\Cache” into your Start Menu’s search box and press enter to open the folder:


Then copy the full path from the explorer window’s address bar and paste it into your Package Manager options:


Click the add button and this time the package manager should accept the new source:


That’s it, thanks for reading!

One thought on “Install NuGet Packages from the Cache

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s