top of page

Belle Movement Group

Public·36 members
Wyatt Morgan
Wyatt Morgan

Restore Tools Pkg Files

The dotnet restore command uses NuGet to restore dependencies as well as project-specific tools that are specified in the project file. In most cases, you don't need to explicitly use the dotnet restore command, since a NuGet restore is run implicitly if necessary when you run the following commands:

Restore Tools Pkg Files


Sometimes, it might be inconvenient to run the implicit NuGet restore with these commands. For example, some automated systems, such as build systems, need to call dotnet restore explicitly to control when the restore occurs so that they can control network usage. To prevent the implicit NuGet restore, you can use the --no-restore flag with any of these commands to disable implicit restore.

To restore the dependencies, NuGet needs the feeds where the packages are located. Feeds are usually provided via the nuget.config configuration file. A default configuration file is provided when the .NET SDK is installed. To specify additional feeds, do one of the following:

For dependencies, you can specify where the restored packages are placed during the restore operation using the --packages argument. If not specified, the default NuGet package cache is used, which is found in the .nuget/packages directory in the user's home directory on all operating systems. For example, /home/user1 on Linux or C:\Users\user1 on Windows.

The behavior of the dotnet restore command is affected by the settings in the nuget.config file, if present. For example, setting the globalPackagesFolder in nuget.config places the restored NuGet packages in the specified folder. This is an alternative to specifying the --packages option on the dotnet restore command. For more information, see the nuget.config reference.

The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used. For more information, see Common NuGet Configurations.

Specifies a runtime for the package restore. This is used to restore packages for runtimes not explicitly listed in the tag in the .csproj file. For a list of Runtime Identifiers (RIDs), see the RID catalog.

Specifies the URI of the NuGet package source to use during the restore operation. This setting overrides all of the sources specified in the nuget.config files. Multiple sources can be provided by specifying this option multiple times.

NuGet Package Restore restores all of a project's dependencies that are listed in either a project file or a packages.config file. You can restore packages manually with nuget restore, dotnet restore, msbuild -t:restore, or through Visual Studio. The dotnet build and dotnet run commands automatically restore packages, and you can configure Visual Studio to restore packages automatically when it builds a project.

During restore, NuGet ignores the order of package sources, and uses the package from the first source that responds to requests. If restore fails, NuGet doesn't indicate the failure until after it checks all sources. NuGet then reports a failure for only the last source in the list. The error implies that the package wasn't present on any of the sources, even though it doesn't list the other failures individually.

In Visual Studio on Windows, you can restore packages automatically or manually. First, configure Package Restore through Tools > Options > NuGet Package Manager.

Select Allow NuGet to download missing packages to enable package restore and the Restore NuGet Packages command. This selection sets the packageRestore/enabled setting to True in the packageRestore section of the global NuGet.Config file, at %AppData%\Roaming\NuGet on Windows or /.nuget/NuGet/ on Mac or Linux.

To enable or disable Package Restore for all users on a computer, you can add the configuration settings to the global NuGet.Config file in Windows at %ProgramData%\NuGet\Config, sometimes under a specific \\ Visual Studio folder, or in Mac/Linux at /.local/share. Individual users can then selectively enable restore as needed on a project level. For more details on how NuGet prioritizes multiple config files, see Common NuGet configurations.

Select Automatically check for missing packages during build in Visual Studio to automatically restore any missing packages when you run a build from Visual Studio. This setting doesn't affect builds run from the MSBuild command line. This selection sets the packageRestore/automatic setting to True in the packageRestore section of the NuGet.Config file.

For non-SDK-style projects, you must select Allow NuGet to download missing packages as well as Automatically check for missing packages during build in Visual Studio in Options to enable automatic restore.

After you enable package restore in Options, you can right-click the solution in Solution Explorer and select Restore NuGet Packages to restore packages anytime.

If you enabled automatic restore in Options, Package Restore happens automatically when you create a project from a template or build a project. For NuGet 4.0+, restore also happens automatically when you make changes to a SDK-style project.

For projects that use , you can see the package references in Visual Studio Solution Explorer under Dependencies > Packages. Packages that don't install properly when you manually restore or run a build display error icons in Solution Explorer. Right-click the project, select Manage NuGet Packages, and use the NuGet Package Manager to uninstall and reinstall the affected packages. For more information, see Reinstall and update packages.

If you see the error This project references NuGet package(s) that are missing on this computer, or One or more NuGet packages need to be restored but couldn't be because consent has not been granted, make sure you enabled automatic restore. For older projects, see Migrate to automatic package restore. Also see Troubleshooting package restore errors.

This command restores packages in projects that use PackageReference for package references. Starting with MSBuild 16.5+, the command also supports packages.config package references, when used with -p:RestorePackagesConfig=true.

When you create a build definition in Azure Pipelines, you can include the NuGet CLI restore or dotnet CLI restore task in the definition before any build tasks. Some build templates include the restore task by default.

Azure DevOps Server and TFS 2013 and later automatically restore packages during build, if you use a TFS 2013 or later Team Build template. You can also include a build step to run a command-line restore option, or optionally migrate the build template to a later version. For more information, see Set up package restore with Team Foundation Build.

By default, NuGet restore operations use packages from the local global-packages and http-cache folders, as described in Manage the global packages and cache folders. To avoid using these local packages, use the following options.

These projects typically contain a .nuget folder with three files: NuGet.config, nuget.exe, and NuGet.targets. The NuGet.targets file causes NuGet to use the MSBuild-integrated approach, so it must be removed.

Package Restore tries to install all package dependencies to the correct state matching the package references in your project file (.csproj) or your packages.config file. (In Visual Studio, the references appear in Solution Explorer under the Dependencies \ NuGet or the References node.) To follow the required steps to restore packages, see Restore packages. If the package references in your project file (.csproj) or your packages.config file are incorrect (they do not match your desired state following Package Restore), then you need to either install or update packages instead of using Package Restore.

These settings can also be changed in your NuGet.Config file; see the consent section. If your project is an older project that uses the MSBuild-integrated package restore, you may need to migrate to automatic package restore.

This situation commonly occurs when you obtain the project's source code from source control or another download. Packages are typically omitted from source control or downloads because they can be restored from package feeds like (see Packages and source control). Including them would otherwise bloat the repository or create unnecessarily large .zip files.

After a successful restore, the package should be present in the global-packages folder. For projects using PackageReference, a restore should recreate the obj/project.assets.json file; for projects using packages.config, the package should appear in the project's packages folder. The project should now build successfully. If not, file an issue on GitHub so we can follow up with you.

The project.assets.json file maintains a project's dependency graph when using the PackageReference management format, which is used to make sure that all necessary packages are installed on the computer. Because this file is generated dynamically through package restore, it's typically not added to source control. As a result, this error occurs when building a project with a tool such as msbuild that does not automatically restore packages.

You may encounter build errors due to missing files, with a message saying to use NuGet restore to download them. However, running a restore might say, "All packages are already installed and there is nothing to restore." In this case, delete the packages folder (when using packages.config) or the obj/project.assets.json file (when using PackageReference) and run restore again. If the error still persists, use nuget locals all -clear or dotnet nuget locals all --clear from the command line to clear the global-packages and cache folders as described on Managing the global packages and cache folders.


Welcome to the group! You can connect with other members, ge...


bottom of page