Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuGet not updating project references

Tags:

nuget

I recently migrated all my Visual Studio 2013 projects to Visual Studio 2015 and followed the steps documented in this article by Nuget to make sure that automatic package restore is still working, in short

  • I deleted the Nuget.exe and Nuget.target files from source control and disk
  • I updated all project files and deleted the sections related to Nuget

I'm experiencing a problem when I'm updating Nuget packages, it is not updating the project references to point to the newest dll versions. I can see that the newest packages was installed though. This problem is also not related to specific packages.

Has anyone else experienced a problem like this?

like image 875
Andre Lombaard Avatar asked Sep 15 '15 05:09

Andre Lombaard


4 Answers

NuGet package restore does not modify the project files. It just downloads and extracts the NuGet packages to the packages directory.

If you are trying to edit the packages.config file and then have the project's updated you would have to use the Package Manager Console and run:

Update-Package -reinstall

Which will uninstall and install the packages again and update the project's references.

like image 117
Matt Ward Avatar answered Oct 04 '22 00:10

Matt Ward


We realized that some of our junior developers only installed the required Nuget packages for ONE project in the solution, they then added references to the required dll's for all other projects by browsing to the physical location of the dll's on disk. This obviously caused the problem because only ONE of the projects in the solution contained entries for Nuget packages in it's packages.config file while the remaining projects in the solution contained none.

When all packages were updated using the Update-Package command only the ONE project containing entries in it's packages.config file were updated with the correct project references.

Even though this is not a Nuget bug and rather a problem caused by inexperience, I logged an issue with Nuget to see if they can improve the software to prevent these types of problems.

like image 43
Andre Lombaard Avatar answered Oct 04 '22 00:10

Andre Lombaard


So I recently had a very similar issue as well, unfortunately uninstalling and reinstalling did not work. Hopefully this helps anyone else as it was very frustrating.

Steps:

  1. go to or launch the quick launch feature.
  2. type package manager
  3. select "tools->Nuget PackageManager-> Package Manager Settings"
  4. In the options window that pops up. click "Clear All Nuget Cache(s)"
  5. Right click solution and select Restore Nuget Packages.

Hope this helps.

like image 3
jtslugmaster08 Avatar answered Oct 03 '22 23:10

jtslugmaster08


I was facing an issue with NuGet package of Newtonsoft.Json as shown below:

enter image description here

I tried all possible solutions but none of the below mentioned ones worked:

  • Cleaning solution
  • Rebuilding solution
  • Clearing NuGet package cache

Finally I realized it had something to do with .NET Framework version targeted by my C# project. There was some mismatch it seems. The moment I upgraded the .NET Framework version of my project to latest, the Newtonsoft.Json package dependency and its reference came alive instantly.

like image 3
RBT Avatar answered Oct 04 '22 01:10

RBT