Skip to content

Commit a889516

Browse files
committed
more updates
1 parent 442154a commit a889516

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

docs/consume-packages/Package-Restore.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,59 +9,59 @@ ms.topic: conceptual
99

1010
# Package Restore
1111

12-
To promote a cleaner development environment and to reduce repository size, NuGet **Package Restore** installs all of a project's dependencies listed in either the project file or `packages.config`. Visual Studio can restore packages automatically when a project is built. In .NET Core 2.0+, the `dotnet build` and `dotnet run` commands also perform an automatic restore. You can also restore packages at any time through Visual Studio, `nuget restore`, `dotnet restore`, and xbuild on Mono.
12+
To promote a cleaner development environment and to reduce repository size, NuGet **Package Restore** installs all of a project's dependencies listed in either the project file or `packages.config`. The .NET Core 2.0+ `dotnet build` and `dotnet run` commands do an automatic package restore. Visual Studio can restore packages automatically when it builds a project, and you can restore packages at any time through Visual Studio, `nuget restore`, `dotnet restore`, and xbuild on Mono.
1313

14-
Package Restore makes sure that all a project's dependencies are available without storing them in source control. To configure your repository to exclude package binaries, see [Packages and source control](../consume-packages/packages-and-source-control.md).
14+
Package Restore makes sure that all a project's dependencies are available, without having to store them in source control. To configure your source control repository to exclude the package binaries, see [Packages and source control](../consume-packages/packages-and-source-control.md).
1515

1616
## Package Restore overview
1717

1818
Package Restore first installs the direct dependencies of a project as needed, then installs any dependencies of those packages throughout the entire dependency graph.
1919

20-
If a package isn't already installed, NuGet first attempts to retrieve it from the [cache](../consume-packages/managing-the-global-packages-and-cache-folders.md). If the package isn't in the cache, NuGet then attempts to download the package from all enabled sources in the list at **Tools** > **Options** > **NuGet Package Manager** > **Package Sources** in Visual Studio. During restore, NuGet ignores the order of package sources, using the package from whichever source is first to respond to requests. For more information about how NuGet behaves, see [Configure NuGet behavior](Configuring-NuGet-Behavior.md).
20+
If a package isn't already installed, NuGet first attempts to retrieve it from the [cache](../consume-packages/managing-the-global-packages-and-cache-folders.md). If the package isn't in the cache, NuGet tries to download the package from all enabled sources in the list at **Tools** > **Options** > **NuGet Package Manager** > **Package Sources** in Visual Studio. During restore, NuGet ignores the order of package sources, and uses the package from whichever source is first to respond to requests. For more information about how NuGet behaves, see [Configure NuGet behavior](Configuring-NuGet-Behavior.md).
2121

2222
> [!Note]
2323
> NuGet doesn't indicate a failure to restore a package until all the sources have been checked. At that time, NuGet reports a failure for only the last source in the list. The error implies that the package wasn't present on *any* of the other sources, even though errors aren't shown for each of those sources individually.
2424
25-
You can trigger Package Restore any of the following ways:
25+
You can trigger Package Restore in any of the following ways:
2626

27-
- **Dotnet command line**: Use the [dotnet restore](/dotnet/core/tools/dotnet-restore?tabs=netcore2x) command to restore packages listed in the project file with [PackageReference](../consume-packages/package-references-in-project-files.md). With .NET Core 2.0 and later, restore happens automatically with `dotnet build` and `dotnet run`.
27+
- **Dotnet command line**: Use the [dotnet restore](/dotnet/core/tools/dotnet-restore?tabs=netcore2x) command to restore packages listed in the project file with [PackageReference](../consume-packages/package-references-in-project-files.md). With .NET Core 2.0 and later, restore happens automatically with the `dotnet build` and `dotnet run` commands.
2828

29-
- **Package Manager** in Visual Studio for Windows: Package Restore happens automatically when you create a project from a template or build a project, subject to the options in [Enable and disable package restore](#enable-and-disable-package-restore)). In NuGet 4.0+, restore also happens automatically when you make changes to a .NET Core SDK-based project.
29+
- **Package Manager**: In Visual Studio for Windows, Package Restore happens automatically when you create a project from a template or build a project, subject to the options in [Enable and disable package restore](#enable-and-disable-package-restore)). In NuGet 4.0+, restore also happens automatically when you make changes to a .NET Core SDK-based project.
3030

31-
To restore manually, right-click the solution in **Solution Explorer** and select **Restore NuGet Packages**. If one or more individual packages still aren't installed properly, **Solution Explorer** shows an error icon. Right-click and select **Manage NuGet Packages**, and use **Package Manager** to uninstall and reinstall the affected packages. For more information, see [Reinstall and update packages](../consume-packages/reinstalling-and-updating-packages.md)
31+
To restore packages manually, right-click the solution in **Solution Explorer** and select **Restore NuGet Packages**. If one or more individual packages still aren't installed properly, **Solution Explorer** shows an error icon. Right-click and select **Manage NuGet Packages**, and use **Package Manager** to uninstall and reinstall the affected packages. For more information, see [Reinstall and update packages](../consume-packages/reinstalling-and-updating-packages.md)
3232

3333
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," [enable automatic restore](#enable-and-disable-package-restore). Also see [Package Restore troubleshooting](Package-restore-troubleshooting.md).
3434

3535
- **NuGet command line**: Use the [nuget restore](../tools/cli-ref-restore.md) command to restore packages listed in a project or solution file, or in `packages.config`.
3636

37-
- **MSBuild**: Use the [msbuild -t:restore](../reference/msbuild-targets.md#restore-target) command to restore packages listed in the project file (PackageReference format only). This command is available only in NuGet 4.x+ and MSBuild 15.1+, which are included with Visual Studio 2017. Both `nuget restore` and `dotnet restore` use this command for applicable projects.
37+
- **MSBuild**: Use the [msbuild -t:restore](../reference/msbuild-targets.md#restore-target) command to restore packages listed in the project file with PackageReference. This command is available only in NuGet 4.x+ and MSBuild 15.1+, which are included with Visual Studio 2017. Both `nuget restore` and `dotnet restore` use this command for applicable projects.
3838

39-
- **Azure Pipelines**: When you create a build definition in Azure Pipelines, include the NuGet [restore](/azure/devops/pipelines/tasks/package/nuget#restore-nuget-packages) or .NET Core [restore](/azure/devops/pipelines/tasks/build/dotnet-core#restore-nuget-packages) task in the definition before any build tasks. Some build templates include this restore task by default.
39+
- **Azure Pipelines**: When you create a build definition in Azure Pipelines, include the NuGet [restore](/azure/devops/pipelines/tasks/package/nuget#restore-nuget-packages) or .NET Core [restore](/azure/devops/pipelines/tasks/build/dotnet-core#restore-nuget-packages) task in the definition before any build tasks. Some build templates include the restore task by default.
4040

41-
- **Azure DevOps Server**: Azure DevOps Server and TFS 2013 and later automatically restore packages during build, if you're using a Team Build Template for TFS 2013 or later. For earlier TFS versions, you can include a build step to invoke 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](../consume-packages/team-foundation-build.md).
41+
- **Azure DevOps Server**: Azure DevOps Server and TFS 2013 and later automatically restore packages during build, if you're using a TFS 2013 or later Team Build template. For earlier TFS versions, you can 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](../consume-packages/team-foundation-build.md).
4242

4343
## Enable and disable package restore
4444

4545
In Visual Studio, you control Package Restore primarily through **Tools** > **Options** > **NuGet Package Manager**:
4646

4747
![Control Package Restore through NuGet Package Manager options](media/Restore-01-AutoRestoreOptions.png)
4848

49-
- **Allow NuGet to download missing packages** controls all forms of package restore by changing the `packageRestore/enabled` setting in the [packageRestore section](../reference/nuget-config-file.md#packagerestore-section) of the `NuGet.Config` file, at `%AppData%\NuGet\` on Windows or `~/.nuget/NuGet/` on Mac/Linux. This setting also enables the **Restore NuGet Packages** command on the solution's context menu in Visual Studio, .
49+
- **Allow NuGet to download missing packages** controls all forms of package restore by changing the `packageRestore/enabled` setting in the [packageRestore section](../reference/nuget-config-file.md#packagerestore-section) of the `NuGet.Config` file, at `%AppData%\NuGet\` on Windows, or `~/.nuget/NuGet/` on Mac/Linux. This setting also enables the **Restore NuGet Packages** command on the solution's context menu in Visual Studio, .
5050

5151
```xml
5252
<configuration>
5353
<packageRestore>
5454
<!-- The 'enabled' key is True when the "Allow NuGet to download missing packages" checkbox is set.
55-
Clearing the box sets this to False, disabling command-line, automatic, and MSBuild-Integrated restore. -->
55+
Clearing the box sets this to False, disabling command-line, automatic, and MSBuild-integrated restore. -->
5656
<add key="enabled" value="True" />
5757
</packageRestore>
5858
</configuration>
5959
```
60+
61+
> [!Note]
62+
> To globally override the `packageRestore/enabled` setting, set the environment variable **EnableNuGetPackageRestore** with a value of True or False before launching Visual Studio or starting a build.
6063

61-
> [!Note]
62-
> To globally override the `packageRestore/enabled` setting, set the environment variable **EnableNuGetPackageRestore** with a value of True or False before launching Visual Studio or starting a build.
63-
64-
- **Automatically check for missing packages during build in Visual Studio** controls automatic restore by changing the `packageRestore/automatic` setting in the [packageRestore section](../reference/nuget-config-file.md#packagerestore-section) of the `NuGet.Config` file. When this option is set to True, running a build from Visual Studio automatically restores any missing packages. This setting doesn't affect builds run from the command line using MSBuild.
64+
- **Automatically check for missing packages during build in Visual Studio** controls automatic restore by changing the `packageRestore/automatic` setting in the [packageRestore section](../reference/nuget-config-file.md#packagerestore-section) of the `NuGet.Config` file. When this option is set to True, running a build from Visual Studio automatically restores any missing packages. This setting doesn't affect builds run from the MSBuild command line.
6565

6666
```xml
6767
...
@@ -75,10 +75,10 @@ In Visual Studio, you control Package Restore primarily through **Tools** > **Op
7575
</configuration>
7676
```
7777

78-
To enable or disable Package Restore for all users on a computer, a developer or company can add the previous settings to the global `nuget.config` file, in Windows at `%ProgramData%\NuGet\Config`, sometimes under a specific `\{IDE}\{Version}\{SKU}\` 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 [Configure NuGet behavior](../consume-packages/configuring-nuget-behavior.md#how-settings-are-applied).
78+
To enable or disable Package Restore for all users on a computer, a developer or company can add the configuration settings to the global `nuget.config` file. The global `nuget.config` is in Windows at `%ProgramData%\NuGet\Config`, sometimes under a specific `\{IDE}\{Version}\{SKU}\` 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 [Configure NuGet behavior](../consume-packages/configuring-nuget-behavior.md#how-settings-are-applied).
7979

8080
> [!Important]
81-
> If you edit the `packageRestore` settings directly in `nuget.config`, restart Visual Studio so that the **Options** dialog box shows the current values.
81+
> If you edit the `packageRestore` settings directly in `nuget.config`, restart Visual Studio, so that the **Options** dialog box shows the current values.
8282

8383
## Constrain package versions with restore
8484

@@ -90,7 +90,7 @@ When NuGet restores packages through any method, it honors any constraints you s
9090
<package id="Newtonsoft.json" version="6.0.4" allowedVersions="[6,7)" />
9191
```
9292

93-
- In a project file that uses PackageReference format, you can specify a version range directly with the dependency's version number. For example:
93+
- In a project file, you can use PackageReference to specify a dependency's range directly. For example:
9494

9595
```xml
9696
<PackageReference Include="Newtonsoft.json" Version="[6, 7)" />

0 commit comments

Comments
 (0)