Or, why you don’t get a nice reassuring green checkmark after an update of a package.
I recently noticed in a rather large solution with around 70 installed NuGet packages (don’t ask) that an update of some packages did not result in a green checkmark. Also when you open the update screen again, it again indicates there is an update for that package. Also when you try to update again it will not allow you to select projects to update since it thinks (knows) all your solution projects already have the update:
I recreated the situation in a simple solution with the following two packages. I have rigged the Json.NET package to display the above behaviour. When I update both packages one gets the green checkmark and the other doesn’t.
This is usually caused by a rogue copy of an old version of the package still in the packages folder under your solution folder:
As you can see above, there is a Newtonsoft.Json.6.0.2 folder, And also the newer installation. There are probably many reasons why this can happen (for instance the EntityFramework package asks for a restart of Visual Studio, and if you don’t do that and just continue on working on your solution it might leave the old version behind). The solution is simple, just delete the folder.
Afterwards it won’t show up in the packages that need updates anymore.
Please be aware that if you have a project under the solution root folder that is not in your solution, but does contain nuget package references, these can still reference the folder you just deleted (and prompty restore it again if you open the project).