Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Some NuGet packages are missing from the solution in Visual Studio Application

After pulling some code updates I found I got this message when building.

Some NuGet packages are missing from the solution. 
The packages need to be restored in order to build the dependency graph. 
Restore the packages before performing any operations

In solution explorer the references links displayed with a missing reference icon

I deleted the references Then at the package manager console a button appeared asking if I wanted to install the missing packages. However, this did not work.

like image 543
Kirsten Avatar asked Nov 20 '16 21:11

Kirsten


3 Answers

I am writing this answer as I tried the below solutions but none of them worked :

  1. Clearing the cache
  2. Restoring or re-installing the packages
  3. Changing the targetFramework
  4. Updating the Nuget Package manager

Then I looked upon a dropdown list and it appeared the error was trivial. The package source was offline !! I installed VS2017 professional on my system and opened an existing project and found that multiple packages were missing. I tried everything I could, without looking at Package Source !!

Manage Nuget Packages for Solution


Solution:

Step 01. Go to Package Manager Settings (Tools > Nuget Package Manager > Package Manager Settings) Nuget Package Manager > Package Manager Settings

Step 02. Check the Package Source(s). As you can see, the package source is here already downloaded SDK/nugets/packages. I don't know the reason but the online package source from nuget.org was missing from my system installation of Visual Studio.

enter image description here

Step 03. Install the nuget.org as package source and then 'Clear All Nuget Cache(s)' and then restore the packages. The error will go away.

Name: nuget.org ( or as you wish) Source: https://api.nuget.org/v3/index.json

enter image description here

like image 94
jainashish Avatar answered Nov 07 '22 02:11

jainashish


When I tried opening the project on its own , outside the solution, and buidling it I received the message.

One or more NuGet packages need to be restored but couldn't be because consent has not been granted. To give consent, open the Visual Studio Options dialog, click on the Package Manager node and check 'Allow NuGet to download missing packages during build.' You can also give consent by setting the environment variable 'EnableNuGetPackageRestore' to 'true'.

I granted VS the permission, then I ran at the package manager console

update-package -Reinstall  
like image 38
Kirsten Avatar answered Nov 07 '22 04:11

Kirsten


Click Ctrl+Q and write the name of the missing package and then click search for online NuGet package matching . It will show menu click on browse that will give you the missing package click install ,uninstall or update. enter image description here

like image 32
I_Al-thamary Avatar answered Nov 07 '22 03:11

I_Al-thamary