19
votes

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?

7
Update-Package -reinstall reinstalls the package, but installs the newest version of all dependencies that package has. Prepare for conflicts..;) - Wogelberg

7 Answers

29
votes

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.

7
votes

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.

3
votes

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.

2
votes

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.

2
votes

Something I just noticed, and I'm not sure if this will help you or anyone else reading this, but this issue literally wracked my brain. The problem was that I was installing packages that I had created myself using NuGet Package Explorer on Windows.

It turned out that, I believe after updating NuGet Package Explorer, it was no longer putting DLLs that I included into the lib folder. Once I started manually adding the lib folder back into the package within Package Explorer, and then uploading to NuGet and reinstalling in the consuming project, that the reference would once again start to appear.

I'm not sure what caused this behavior - it could have been my own fault, but I literally just now figured this out - and consequently have to go back and re-do a whole bunch of NuGet package goodness that I've done over the past month. OUCH.

Hope this saves someone at least an ounce of pain.

1
votes

None of the above worked for me.

What did work, was to edit the project file directly and delete the existing reference. When I reloaded the project, the package then showed up in references as a Nuget package.

0
votes

I happened to come across the same problem. i tried all the possible solution but found the solution - just open the .proj file in an text editor and check the package Version and the HintPath in the Reference tag. Sometime there is an mismatch correct it then Visual studio will recognize. I hope everyone can save lot of time. Here is an sample to refer

<Reference Include="nunit.framework, Version=3.4.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb">
      <HintPath>..\packages\NUnit.3.4.1\lib\net45\nunit.framework.dll</HintPath>
</Reference>