Troubleshooting package restore errors in Visual Studio


This page focuses on common errors when restoring packages in Visual Studio and steps to resolve them. For how-to restore packages, see Package restore.

By default, building a project in Visual Studio automatically restores NuGet packages referenced in the project. However, builds will fail if package restore is disabled in the Tools > Options > NuGet Package Manager > Package Restore settings and the necessary packages are not available on your computer. In these cases you may see the following errors:

This project references NuGet package(s) that are missing on this computer.
Use NuGet Package Restore to download them. The missing file is {name}.
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 NuGet 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'. Missing packages: {name} 

To enable package restore, open Tools > Options > NuGet Package Manager and select the options for Allow NuGet to download missing packages and Automatically check for missing packages during build in Visual Studio:

enable NuGet package restore in Tool/Options