Cached nuget packages causing you problems?

Short version
If you are having problems with nuget packages and think it might be related to local caching delete packages from these directories –

%LocalAppData%\NuGet\Cache
and
%userprofile%\.nuget\packages\

Long version
I was making nuget package, lets call it Foo, for my own use, not one that I was going to distribute publicly, but I was putting in on MyGet.

I had a few classes in it and after making the nuget package, I uploaded it to MyGet. I then switched to the Business solution and referenced this newly created nuget package.

After doing a little bit of work, I noticed that I had incorrectly made a class internal rather than public in the Foo nuget package.

No problem, back to the Foo solution where I was making the library, change the class to public, rebuild, and remake the nuget package. I didn’t want to increment the version number, so I left it at 1.0.0. On MyGet I deleted the old package and then uploaded the new one.

Here’s what I tried and didn’t work –

  • In the Business solution referencing the Foo nuget package, I uninstalled Foo and then reinstalled it.
  • But Visual Studio still reported that the class was inaccessible!
  • Uninstall and reinstall again, same problem!!
  • Delete the Foo directory from the packages directory beside the solution file, remove the Foo line from the packages.config. Reinstall Foo. Same problem!!!
  • Recomplie Foo, delete Foo from MyGet, reupload Foo to MyGet. Reinstall Foo. Still inaccessible!!!!
  • WTF!!!!!

And this is what works –

  • Download the Foo nuget package directly from MyGet and reference it directly. Success! There must be a local cache that Visual Studio is using!!!!!!

Yes there are, I found two –

%LocalAppData%\NuGet\Cache
and
%userprofile%\.nuget\packages\

Delete the offending nuget package; back in Visual Studio I can now successfully install the nuget package.

In general avoid using the same package version number when uploading a new package to MyGet.