How to access Nuget when internet is down or not available

One thing any .NET developer is addicted to is Nuget Package Manger. Life has become so easy, no more hassle of maintain all those 3rd party libraries or remember them or list them down in some document. No more Reference DLL not found errors to deal with and all credits goes to Nuget. Nuget handles it all for you and gets whatever is needed from Nuget Server on demand or as configured.

I am writing this one specifically cause there are situations when

  • you might not be having internet access

  • or Nuget.org went under maintenance

  • or you are in some remote area on earth (or other planet)

  • or in a plane

  • or internet access is prohibited in your organization (as in my case on my office Developer VM pffff)

Every time you add a package from NuGet or using NuGet package manger, it create a cache copy of that package in a special folder on your machine.

You can see list of all packages you have used till now on your machine at following path:

C:\Users\[Your User Name]\AppData\Local\NuGet\Cache\

This cache can be used in case you cannot connect to NuGet Server directly. All you need to do is configure one more package source in your NuGet package manager settings in Visual Studio (VS2012 in my case).

Step 1: Open you awesome Visual Studio 2012

Step 2: Go to > Tools > Options

Step 3: In Options dialog > Find "Package manger settings" and select > "Package Sources"

Nuget package source settings

Here you can see the default NuGet Server package source path, https://www.nuget.org/api/v2/

Step 4: Click on Plus sign at top-right corner and add a new package source

Add new package source

Give name to the new package source (whatever suits you) and provide path to your NuGet cache folder in Source input > Click on Update  and OK to close the options dialog.

Step 5: Open any project and right click on the project node and select > "Manage NuGet Packages"

Manage nuget packages

Step 6: Here you can see your newly configured NuGet package source along with default nuget.org package sources. Yes you can use it without internet access, without any concern or contact with NuGet server. Only catch is this is the cache copy so you will have to manually put updates for the package you use if you are planning to move them to other folder or place, as this is only a cache copy.

I think my internet is down, working !!

You can clear some space in your C:\ drive or remove all this cached packages by clicking "Clear Package Cache" in Tools > Options > Package Manager > General Settings

Clear package cache