What to do if Visual Studio won’t download the DLL for a NuGet package

One annoying problem is when sometimes you try to build your solution, only to get a pile of compilation errors due to a missing DLL. This is often caused by one of the DLLs not downloading from NuGet. The package will be in packages.config, but only the .pdb file gets downloaded.

Even more annoying is when you’re the only developer to have this problem. Everyone else can build the solution without problem.

The answer is fairly simple, but not obvious…

First close all instances of Visual Studio. This is generally a good idea when doing anything outside of VS that will affect what VS thinks is going on.

As you saw, you need to use the command line version of nuget to clear your cache. Your first problem is finding this, as it’s not obvious. Your second problem (if you search for it) is that you’ll find loads of them, one in the .nuget folder in each solution.

The easiest way to get around this is to download the latest nuget.exe from their web site. Save it somewhere away from any projects in case you need it again.

At this point, you won’t be able to run the command to clear the cache, as you’ll need to upgrade nuget itself first. I agree that this seems odd, given that you’ve just downloaded the latest, but you’ll need to do the following…

nuget update -self

Once you’ve done that, you can then clear your cache as jessehouwing mentioned…

nuget.exe locals all -clear

When you next start Visual Studio, you should find that all works as expected. You may need to uninstall and reinstall the packages to get it all working, but with the cache cleared, that should work without problem.

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.