You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/consume-packages/configuring-nuget-behavior.md
+28-17Lines changed: 28 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ ms.topic: conceptual
9
9
10
10
# Common NuGet configurations
11
11
12
-
NuGet's behavior is driven by the accumulated settings in one or more `NuGet.Config` (XML) files that can exist at solution- (project if no solution is used), user-, and computer-wide levels. A global `NuGetDefaults.Config` file also specifically configures package sources. Settings apply to all commands issued in the CLI, the Package Manager Console, and the Package Manager UI.
12
+
NuGet's behavior is driven by the accumulated settings in one or more config (XML) files that can exist at solution- (project if no solution is used), user-, and computer-wide levels.
13
13
14
14
## Config file locations and uses
15
15
@@ -58,29 +58,35 @@ Settings are managed using the NuGet CLI [config command](../reference/cli-refer
58
58
Windows:
59
59
60
60
```cli
61
-
# Set repositoryPath in the user-level config file
62
-
nuget config -set repositoryPath=c:\packages
61
+
# Set globalPackagesFolder in the user-level config file
62
+
dotnet nuget config set globalPackagesFolder "C:\packages"
63
+
64
+
# Set repositoryPath (available for packages.config only) in the user-level config file
65
+
dotnet nuget config set repositoryPath "C:\packages"
Copy the template below into the new file and then use `nuget config -configFile <filename>` to set values:
109
+
Using the .NET CLI, create a default nuget.config by running `dotnet new nugetconfig`.
110
+
For more information, see [dotnet CLI commands](../reference/dotnet-commands.md#package-consumption).
111
+
112
+
Alternatively, manually copy the template below into the new file and then use `nuget config -configFile <filename>` to set values:
104
113
105
114
```xml
106
115
<?xml version="1.0" encoding="utf-8"?>
@@ -116,7 +125,7 @@ If a command line tool is used on a project file, rather than a solution file, t
116
125
117
126
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:
118
127
119
-
1. The [`NuGetDefaults.Config` file](#nuget-defaults-file), which contains settings related only to package sources.
128
+
1.(*Uncommon*) The [`NuGetDefaults.Config` file](#nuget-defaults-file), which contains settings related only to package sources.
120
129
1. The computer-level file.
121
130
1. The user-level file.
122
131
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`.
@@ -154,9 +163,9 @@ File A. User-level file, (`%appdata%\NuGet\NuGet.Config` on Windows, `~/.config/
154
163
```xml
155
164
<?xml version="1.0" encoding="utf-8"?>
156
165
<configuration>
157
-
<activePackageSource>
158
-
<addkey="NuGet official package source"value="https://api.nuget.org/v3/index.json" />
@@ -226,7 +235,9 @@ These files cannot be edited by the standard tooling.
226
235
227
236
## NuGet defaults file
228
237
229
-
The `NuGetDefaults.Config` file exists to specify package sources from which packages are installed and updated, and to control the default target for publishing packages with `nuget push`. Because administrators can conveniently (using Group Policy, for example) deploy consistent `NuGetDefaults.Config` files to developer and build machines, they can ensure that everyone in the organization is using the correct package sources rather than nuget.org.
238
+
The `NuGetDefaults.Config` is uncommon and can only specify package sources from which packages are installed and updated, or control the default target for publishing packages with `nuget push`.
239
+
240
+
Because administrators can conveniently (using Group Policy, for example) deploy consistent `NuGetDefaults.Config` files to developer and build machines, they can ensure that everyone in the organization is using consistent package sources, whether or not that includes nuget.org.
230
241
231
242
> [!Important]
232
243
> The `NuGetDefaults.Config` file never causes a package source to be removed from a developer's NuGet configuration. That means if the developer has already used NuGet and therefore has the nuget.org package source registered, it won't be removed after the creation of a `NuGetDefaults.Config` file.
0 commit comments