Tuesday, September 22, 2015

Visual Studio 2013–Reinstall a NuGet package

Last week I had a situation where I wanted to replace a NuGet package. The problem was that the NuGet Package version was not updated but the content was changed (I know, not a good idea). So what I wanted is that the system remove the existing package and reinstall it from the NuGet repository. 

First thing I tried was the following command:

Update-Package –reinstall <package name>

The command succeeded but when I checked the content of the NuGet Package it contained still the old content.

Afterwards I tried a different approach:

  • I deleted the reference from my project
  • Edited the packages.config to remove the reference to the NuGet package
  • Removed the NuGet package from the file system

After removing everything manually, I did a new install:

Install-Package <package name>

But again, no luck. When I checked the content of the NuGet Package the old content was still there…

In the end I was able to solve the issue by clearing the package cache:

  • In Visual Studio, go to Tools –> NuGet Package Manager –> Package Manager Settings
  • On the General tab, click on the Clear Package Cache button
  • Afterwards the ‘Update-Package –reinstall’ worked as expected


No comments: