Nuget Packages are there but missing References

Visual Studio-2015Nuget

Visual Studio-2015 Problem Overview


After branching in TFS, VS2015 Update 2 has missing references to all Nuget packages. Package restore says "All packages listed in packages.config are already installed."

I could manually add references to all of the packages in the \packages folder but why isn't VS already checking there?

Visual Studio-2015 Solutions


Solution 1 - Visual Studio-2015

You need use the NuGet command line in the Package Manager Console:

Update-Package -reinstall

to force reinstall the package references into project.

NuGet Restore only restores files in the packages directory (\packages folder ), but does not restore files inside your project or otherwise modify your project. For example, if a package has added some reference DLLs or other files in your project, if you delete any of these files, they will not be re-added when restoring this package. This may cause the your project to not be able to find the missing dependencies when building.

So use the "Update-Package -reinstall" command to force reinstall the package references and content files into project.

Solution 2 - Visual Studio-2015

This worked for me:

  • Unload proj from solution
  • Edit csproj file and delete nuggets entries from csproj file (ItemGroup).
  • Reload proj

Solution 3 - Visual Studio-2015

as found for VS2013 by Shivam (https://stackoverflow.com/a/46763556/1034160) , my solution in VS2017 was to clear Nuget cache from: Options -> NugetPackageManager -> Clear All NuGet Cache(s)

Solution 4 - Visual Studio-2015

If you cloned the project from a git repository and if the folder created while cloning has a '%20' in it. Then rename folder, get rid of '%20'. This should help to find the package dll's within the project.

Solution 5 - Visual Studio-2015

Go to ->

  1. Tools -> Nuget Package Manager -> Package Manager Settings
  2. Under Nuget Package Manager -> General Tab
  3. Do Clear Cache
  4. Restart Visual studio and Restore all Nuget Packages.
  5. This will refresh all the references.

Solution 6 - Visual Studio-2015

I have had to recently add a Project to a very large Solution that contains multiple NugGet packages from multiple sources. My solution has been to run the Update-Package -reinstall in the Package Manager Console. Upon completion, all of the existing Projects will get an update. If you are using GIT, I recommend going into your Team Explorer and Undo all of the Changes to the Other projects that were updated, however keep the Changes for the new Project. Your references will be there and your "using" statements will not have that annoying squiggly red lines:)

Solution 7 - Visual Studio-2015

One solution that worked for me is:

  1. Go to Tools > NuGet Package Manager > Package Manager Settings.
  2. On the left pane, click on Package sources under Nuget Package Manager.
  3. Then ensure you have these settings:

enter image description here

And then restart VS and Restore the packages.

Solution 8 - Visual Studio-2015

I cleared my nuget cache after having an issue trying to install a package and experienced this issue... all my packages were there but reference errors everywhere. I was also unable to uninstall/reinstall a package and nuget console commands did not work either such as Update-Package -Reinstall -ProjectName Your.Project.Name. Nor did manually attempting to remove them from the csproj file as well as manually adding them by browsing directly to the package .dll's via 'add reference' on the solution menu tree in the ide.

Luckily I had backed up my entire project folder that morning via an outright .zip. I was forced to update my VS 2019 version to latest (Version 16.10.1 at time of this) and then restore to my backup and was fixed.

I will never clear the nuget cache again

Solution 9 - Visual Studio-2015

  1. Right click on project, click unload project.
  2. Right click on project, click edit csproj file
  3. Remove below tag name from cproj file and save ..............
  4. Right click on project and ReLoad project

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionShilohView Question on Stackoverflow
Solution 1 - Visual Studio-2015Leo Liu-MSFTView Answer on Stackoverflow
Solution 2 - Visual Studio-2015pabbenView Answer on Stackoverflow
Solution 3 - Visual Studio-2015stefanoView Answer on Stackoverflow
Solution 4 - Visual Studio-2015Madan KumarView Answer on Stackoverflow
Solution 5 - Visual Studio-2015Siddharth BView Answer on Stackoverflow
Solution 6 - Visual Studio-2015SotaboundView Answer on Stackoverflow
Solution 7 - Visual Studio-2015Zenobia PanvelwallaView Answer on Stackoverflow
Solution 8 - Visual Studio-2015MX313View Answer on Stackoverflow
Solution 9 - Visual Studio-2015Jagram singhView Answer on Stackoverflow