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.
I am writing this answer as I tried the below solutions but none of them worked :
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 !!
Solution:
Step 01. Go to Package Manager Settings (Tools > 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.
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
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With