19

I have multiple projects referencing the same NuGet Package. When I got latest code, I realized that one of the projects had an updated package.config and also updated reference to the Dll that is provided by that package.

Now, I also updated package.config on other prjects hoping the as soon as I do an upgrade on that NuGet engine will see that and fetch me new DLLs. Well, it did not happen. After that I tried following things and none of them worked:

  1. Deleting the old version of DLL and then doing Restore package
  2. Deleting the packages folder, restarting my VS 2015 and restoring the package

Also, funny thing is that when I go to Manage Nuget Packages and look at the package for which I need new DLL, it shows that it is already at new version and I do not need to upgrade it.

Is there any ways I can get NuGet engine to upgrade these packages?

Lost
  • 12,007
  • 32
  • 121
  • 193

2 Answers2

24

Just editing the packages.config file will not cause Visual Studio to make any changes to your project. Also NuGet restore does not modify your project. NuGet restore just downloads the NuGet packages and makes them available for your project.

Instead of editing the packages.config file I would just use the NuGet Package Manager in Visual Studio, or the Package Management Console, to update the NuGet package in the projects required.

Other alternatives include updating the project files (.csproj) to use the correct updated assembly references. Or you can run an Update-Package -reinstall to force the NuGet packages to be uninstalled and installed again in the projects. That will fix the assembly references.

Matt Ward
  • 47,057
  • 5
  • 93
  • 94
  • 2
    "Update-Package -reinstall" certainly caused my missing references to be added to my project after I manually edited the packages.config file. – Greg Trevellick Jun 14 '17 at 06:28
  • In my cacse "Update-Package -reinstall" has reverted manual changes I've made in packages.config, VS 2017 – sarh Jun 08 '20 at 21:16
1

If your solution can be opened by Visual Studio 2017, I suggest to use the latest PackageReference to manage nuget. Packages.config has several drawbacks and PackageReference solve these problems.

Here's the solution to migrate to PackageReference: https://github.com/NuGet/Home/wiki/Packages.config-to-PackageReference-Migrator

Also, you can this use this vs extension: https://marketplace.visualstudio.com/items?itemName=TaylorSouthwickMSFT.NuGetPackagetoProjectjsonConverter

Feiyu Zhou
  • 4,344
  • 32
  • 36