Skip to content

Commit e65b648

Browse files
nuget: Correct onf loading rules with explicit config file (#3262)
When -configFile is given for nuget.exe, or --configfile for `dotnet restore`, only the specified file is scanned for configuration, and the hierarchical config loading behavior is not used. This aligns the general documentation with the specific behaviour of these tools.
1 parent c245fcd commit e65b648

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

docs/consume-packages/configuring-nuget-behavior.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,15 @@ Multiple `NuGet.Config` files allow you to store settings in different locations
114114
These settings collectively apply to any NuGet operation invoked from the command line or from Visual Studio, with settings that exist "closest" to a solution or the current folder taking precedence.
115115
If a command line tool is used on a project file, rather than a solution file, then the project directory is used as the "solution directory", which can lead to inconsistent behaviour when there is a `NuGet.Config` file in a subdirectory of the solution file.
116116

117-
Specifically, NuGet loads settings from the different config files in the following order:
117+
Specifically, when a config file is not specified explicitly on the command line, NuGet loads settings from the different config files in the following order:
118118

119119
1. The [`NuGetDefaults.Config` file](#nuget-defaults-file), which contains settings related only to package sources.
120120
1. The computer-level file.
121121
1. The user-level file.
122-
1. The file specified with `-configFile`.
123122
1. Files found in every folder in the path from the drive root to the current folder (where `nuget.exe` is invoked or the folder containing the Visual Studio solution). For example, if a command is invoked in `c:\A\B\C`, NuGet looks for and loads config files in `c:\`, then `c:\A`, then `c:\A\B`, and finally `c:\A\B\C`.
124123

124+
When a config file is explicitly specified on the command line, for example `nuget -configFile my.config` or `dotnet restore --configfile my.config`, only the settings from the specified file will be used.
125+
125126
As NuGet finds settings in these files, they are applied as follows:
126127

127128
1. For single-item elements, NuGet replaced any previously-found value for the same key. This means that settings that are "closest" to the current folder or solution override any others found earlier. For example, the `defaultPushSource` setting in `NuGetDefaults.Config` is overridden if it exists in any other config file.

0 commit comments

Comments
 (0)