Enable Nuget Package Restore

Enable Nuget Package Restore

Enabling NuGet Package Restore ensures your project automatically downloads missing dependencies before build. Here’s how to do it depending on your setup.

1) Visual Studio (recommended way)

In Microsoft Visual Studio:

Enable globally

• Go to Tools → Options
• Navigate to NuGet Package Manager → General
• Check:
  - Allow NuGet to download missing packages
  - Automatically check for missing packages during build

Enable per solution

Right-click the solution
Select Restore NuGet Packages

Or:

Right-click solution → Manage NuGet Packages → Restore

2) Using .csproj (modern .NET / SDK-style)

For SDK-style projects (most .NET Core / .NET 5+), restore is automatic.

Just run:

dotnet restore

Using .NET CLI

You usually don’t need to enable anything—restore happens before build.

3) Command Line (manual restore)

Using .NET CLI

dotnet restore

Using NuGet CLI

nuget restore YourSolution.sln

4) MSBuild (CI/CD pipelines)

In build pipelines:

msbuild YourSolution.sln /t:Restore

Or:

dotnet build

(which includes restore automatically)

5) Enable in older (packages.config) projects

For legacy projects:

Right-click solution

Click Enable NuGet Package Restore (older Visual Studio versions)

This creates:

• .nuget folder
• NuGet.config
• nuget.exe

6) Auto-restore on build

Modern setups already do this, but ensure:

<RestorePackages>true</RestorePackages>

(rarely needed today)

Common issues & fixes

Packages not restoring?

Run:

dotnet restore --force

Clear cache:

dotnet nuget locals all --clear

Still cannot enable Nuget Package Restore, try this!

To enable Nuget Package Restore, first check if package restore is enabled from the visual studio options.

Allow Nuget to download missing packages

Open visual studio and follow the steps given below:

Tools / Options / NuGet Package Manager / Allow NuGet to download missing packages

Lastly check the checkbox for "Allow NuGet to download missing packages" as shown in the following image.

Nuget package manager options

If it is already enabled open Nuget Package Manager console:

Tools / NuGet Package Manager / Package Manager Console

Run the command

Install-Package NuGetEnablePackageRestore

You may get the result

========================
NuGet Enable Package Restore Fix
========================
To fix package restore:
1. Please enable package restore in Visual Studio FIRST.
2. Run the command: Install-NuGetEnablePackageRestoreFix 
3. Restart Visual Studio.

This should fix that pesky broken build you are experiencing.

Then, just run the command 

Install-NuGetEnablePackageRestoreFix

and restart Visual Studio.

How CSharp © 2007 Sitemap, Privacy Policy, Contact