Search code examples
visual-studio-2015nuget

Visual Studio not downloading DLL for NuGet package


We have a few NuGet packages on our local TeamCity server, and use these in various projects. I have just come back from holiday, grabbed the latest from source code, and tried to rebuild, only to get a pile of compilation errors due to a missing DLL.

It seems that the DLL for one of our packages was not downloaded from NuGet. I tried starting a new WPF project, and adding three of the packages. All three appear in the packages.config file, but only two of them have the DLLs downloaded. The third has only the *.pdb file downloaded.

No-one else on the team has this problem, and I tried it on my spare machine, and it downloaded fine, so it looks like it's an issue with my machine, Visual Studio or NuGet installation. However, as I can grab other packages from the same source without problem, it doesn't look like it's a global problem with either VS or NuGet.

I realise there isn't much to go on, but I don't know what else to tell you. If anyone can suggest anything, I would be very grateful. As the package source is our own, I can't share that unfortunately.

I'm using Visual Studio Enterprise 2015 Update 3 (build 14.0.25424.00) with NuGet package manager version 3.4.4.1321 on Windows 10 Pro 64 bit (version 1607, build 14393.105). If there's anything else I can add, please let me know.


Solution

  • Posting this as an answer so others can find it, even though you seem to have found the answer yourself. I've been through this problem, so understand your issue.

    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.

    Hope that's all clear.