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?

3
  • 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" Sep 7, 2014 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 ( Sep 7, 2014 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). Sep 7, 2014 at 12:13

1 Answer 1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.