8

I open my project, using nuget - restore my packages, but as i see not all. For example Newtonsoft.Json is missing. I try to install it again using package manager console but get message 'already has a reference to Newtonsoft.Json (version)'

How can i fix this problem with references?

user3625486
  • 151
  • 1
  • 10
  • It happens. I generally have to delete the packages.config and remove the packages folder completely. Re-add all the nuget dependencies. There are also two ways to have nuget restore packages; "automatic package restore" (better way), or "MSBuild-Integrated package restore" – Meirion Hughes Sep 07 '14 at 12:02
  • @MeirionHughes, thanks fo reply. Yes, i try to remove packages folder and then restore it, try to enable nuget restore, but this doesn't help ( – user3625486 Sep 07 '14 at 12:09
  • When you make a project DONT "enable nuget restore", just add nuget packages and build; nuget will automatically restore, but a different way. When you do the "enable nuget restore" it modifies your solution file and adds the nuget folder and exe. I have found this nothing but trouble; (its the MSBuild option). – Meirion Hughes Sep 07 '14 at 12:13

1 Answers1

9

Usually when NuGet doens't restore the packages the problems are:

The most common:

  1. You have the folder of the package you are trying to restore inside the "packages" folder (i.e. "Packages/EntityFramework.6.0.0/") but the "DLLs" are not inside it (most of the version control systems automatically ignore ".dll" files). This occurs because before NuGet tries to restore each package it checks if the folders already exist, so if it exists, NuGet assumes that the "dll" is inside it. So just delete the folder that NuGet will restore it correctly.

Less common (for old Visual Studio versions):

  1. You have not enabled the "NuGet Package Restore" https://stackoverflow.com/a/23917432/890890
fabriciorissetto
  • 9,475
  • 5
  • 65
  • 73