Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuget doesn't restore all packages

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?

like image 670
user3625486 Avatar asked Sep 07 '14 11:09

user3625486


People also ask

How do I force a NuGet package to restore?

Restore NuGet packagesNavigate to Tools > Options > NuGet Package Manager > General, and then select the Allow NuGet to download missing packages check box under Package Restore. Enabling Restore NuGet Packages. In Solution Explorer, right-click the solution, and then select Restore NuGet Packages.

How do I fix a missing NuGet package?

Quick solution for Visual Studio usersSelect the Tools > NuGet Package Manager > Package Manager Settings menu command. Set both options under Package Restore. Select OK. Build your project again.

What is the difference between NuGet restore and dotnet restore?

nuget restore will ensure all of your NuGet dependencies are downloaded and available to your project. Whereas dotnet restore is a complete restoration of all NuGet dependencies as well as references and project specific tools. Meaning that if you run nuget restore , you are only restoring NuGet packages.


1 Answers

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
like image 56
fabriciorissetto Avatar answered Nov 02 '22 07:11

fabriciorissetto