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
@@ -21,6 +19,7 @@ We also have suggestions for other [best practices](..\concepts\Security-Best-Pr
21
19
22
20
Package Source Mapping was added in [NuGet 6.0](..\release-notes\NuGet-6.0.md).
23
21
Starting with Visual Studio 17.5, you can add and remove Package Source Mappings with the Visual Studio Options Dialog.
22
+
For detailed information on all Visual Studio NuGet options, see [NuGet Options in Visual Studio](nuget-visual-studio-options.md).
24
23
25
24
### Visual Studio support
26
25
@@ -55,34 +54,23 @@ To opt into this feature, you must have a `nuget.config` file. Having a single `
55
54
56
55
_From the Package Manager UI_
57
56
58
-
- Select a package from the list to show it in the Details Pane.
59
-
- Press the `Configure` button to open the Package Source Mappings options page.
57
+
* Select a package from the list to show it in the Details Pane.
58
+
* Press the `Configure` button to open the Package Source Mappings options page.
60
59
61
60

62
61
63
62
_From the Visual Studio Options Dialog_
64
63
65
-
- Go to the `Tools` menu in the main Visual Studio toolbar, and choose `NuGet Package Manager` -> `Package Manager Settings`.
66
-
- Navigate to the `Package Source Mappings` page.
64
+
* Go to the `Tools` menu in the main Visual Studio toolbar, and choose `NuGet Package Manager` -> `Package Manager Settings`.
65
+
* Navigate to the `Package Source Mappings` page.
67
66
68
-

67
+
For details about managing NuGet package source mappings, see [NuGet Options in Visual Studio](nuget-visual-studio-options.md#package-source-mapping).
69
68
70
-
3. Press the `Add` button in the `Package Source Mappings` page to open the `Add Package Source Mappings` dialog.
4. Enter a Package ID or Package Pattern, and select one or more package source(s) by toggling the checkbox for your desired source(s).
74
-
75
-

76
-
77
-
5. The `Package Source Mapping` options page will show the newly created source mapping.
78
-
79
-

80
-
81
-
6. Press `OK` on the Options Dialog to save changes to the applicable `nuget.config`.
82
-
7. The NuGet Package Manager window will refresh and reflect the new status of the selected package's source mappings.
69
+
The NuGet Package Manager window will refresh and reflect the new status of the selected package's source mappings.
83
70

84
71
85
72
### Enable by manually editing `nuget.config`
73
+
86
74
* Declare your desired package sources in your `nuget.config` file.
87
75
* Following your source declarations, add a `<packageSourceMapping>` element that specifies the desired mappings for each source.
88
76
* Declare exactly one `packageSource` element for each source in use.
@@ -124,9 +112,9 @@ For maximum flexibility and control, NuGet requires that all packages match a pa
124
112
125
113
### Package Pattern requirements
126
114
127
-
All requested packages must map to one or more sources by matching a defined package pattern. In other words, once you have defined a `packageSourceMapping` element you must explicitly define which sources *every* package - *including transitive packages* - will be restored from.
115
+
All requested packages must map to one or more sources by matching a defined package pattern. In other words, once you have defined a `packageSourceMapping` element you must explicitly define which sources _every_ package - _including transitive packages_ - will be restored from.
128
116
129
-
* Both top-level *and transitive* packages must match defined patterns. There is no requirement that a top level package and its dependencies come from the same source.
117
+
* Both top-level _and transitive_ packages must match defined patterns. There is no requirement that a top level package and its dependencies come from the same source.
130
118
* The same ID pattern can be defined on multiple sources, allowing matching package IDs to be restored from any of the feeds that define the pattern. However, this isn't recommended due to the impact on restore predictability (a given package could come from multiple sources). This may be a valid configuration if you trust all respective sources.
131
119
132
120
### Package Pattern Syntax
@@ -165,7 +153,7 @@ For manual onboarding you may take the following steps:
165
153
1. Run [dotnet restore](/dotnet/core/tools/dotnet-restore) to restore dependencies.
166
154
1. Run [`dotnet list package --include-transitive`](/dotnet/core/tools/dotnet-list-package#synopsis) to view all top-level and transitive packages in your solution.
167
155
* For .NET framework projects using [`packages.config`](../reference/packages-config.md), the `packages.config` file will have a flat list of all direct and transitive packages.
168
-
1. Define mappings such that every package ID in your solution - *including transitive packages* - matches a pattern for the target source.
156
+
1. Define mappings such that every package ID in your solution - _including transitive packages_ - matches a pattern for the target source.
169
157
1. Run [dotnet nuget locals global-packages -c](/dotnet/core/tools/dotnet-nuget-locals) to clear global-packages directory.
170
158
1. Run restore to validate that you have configured your mappings correctly. If your mappings don't fully cover every package ID in your solution, the error messages will help you identify the issue.
171
159
1. When restore succeeds, you are done! Optionally consider:
@@ -174,7 +162,7 @@ For manual onboarding you may take the following steps:
174
162
175
163
#### Automated onboarding using tool
176
164
177
-
Many repositories have a large number of packages and doing the work manually can be time consuming. The [NuGet.PackageSourceMapper tool](https://www.nuget.org/packages/NuGet.PackageSourceMapper) can automatically generate a NuGet.config for you, based on your project's known packages and sources.
165
+
Many repositories have a large number of packages and doing the work manually can be time consuming. The [NuGet.PackageSourceMapper tool](https://www.nuget.org/packages/NuGet.PackageSourceMapper) can automatically generate a NuGet.config for you, based on your project's known packages and sources.
178
166
179
167
The package source mapper tool requires you to have completed a successful package restore in which it will read each respective `.nupkg.metadata` file generated as part of your build to best understand how you map your respective packages and sources. Tool not only covers top dependencies it also considers all the transitive dependencies when generating mapping.
180
168
@@ -183,6 +171,7 @@ Tool has several option how to generate mapping pattern depending on your need,
183
171
For an idea of how your source mappings may look like, refer to our [samples repo](https://github.com/NuGet/Samples/tree/main/PackageSourceMappingExample).
184
172
185
173
> [!Note]
174
+
>
186
175
> * There are no nuget.exe or dotnet.exe commands for managing the package source mapping configuration, see [NuGet/Home#10735](https://github.com/NuGet/Home/issues/10735).
187
176
> * There are no means of mapping packages at package installation time, see [NuGet/Home#10730](https://github.com/NuGet/Home/issues/10730).
188
177
> * There is a limitation when using the `DotNetCoreCLI@2` Azure Pipelines task which can be worked around by using `feed-` prefixes in your source mapping configuration. It is recommended however to use `NuGetAuthenticate` for your authentication needs and call the dotnet cli directly from a script task. See [microsoft/azure-pipelines-tasks#15542](https://github.com/microsoft/azure-pipelines-tasks/issues/15542).
@@ -48,7 +45,7 @@ To find and install a NuGet package with Visual Studio, follow these steps:
48
45
> In Visual Studio 17.11 and higher, package owners are shown as profile hyperlinks when supported by the selected package source.
49
46
> Package ownership is defined by the package source. For example, see [Manage package owners on nuget.org](../nuget-org/publish-a-package.md#manage-package-owners-on-nugetorg).
50
47
>
51
-
> In Visual Studio 17.10 and earlier, the package _author_ metadata is shown, which appears as plain-text.
48
+
> In Visual Studio 17.10 and earlier, the package *author* metadata is shown, which appears as plain-text.
52
49
> For more information, see [Authors package metadata](../create-packages/package-authoring-best-practices.md#authors).
53
50
54
51
- Select a package to see detailed package information.
@@ -129,8 +126,6 @@ In this example, the ClassLibrary1 project is using EntityFramework 6.2.0, where
129
126
130
127
Visual Studio ignores the order of package sources, and uses the package from whichever source is the first to respond to a request. For more information, see [Restore packages](package-restore.md). For information about how to load a package from a specific source, see [Package source mapping](package-source-mapping.md).
131
128
132
-
To manage NuGet package sources, follow these steps:
133
-
134
129
1. To change the source from which Visual Studio loads package metadata, select a source from the **Package source** selector.
135
130
136
131

@@ -139,21 +134,7 @@ To manage NuGet package sources, follow these steps:
139
134
140
135

141
136
142
-
1. In the **Options** window, expand the **NuGet Package Manager** node and select **Package Sources**.
143
-
144
-

145
-
146
-
1. To add a source, select **+**, edit the **Name**, enter the URL or path in **Source**, and then select **Update**.
147
-
148
-
The source now appears in the **Package source** dropdown list.
149
-
150
-
1. To change a package source, select it, make edits in the **Name** and **Source** boxes, and select **Update**.
151
-
152
-
1. To disable a package source, clear the box to the left of the name in the list.
153
-
154
-
1. To remove a package source, select it, and then select the **X** button.
155
-
156
-
If a package source reappears after you delete it, it might be listed in a computer-level or user-level *NuGet.config* file. For the location of these files, see [Common NuGet configurations](../consume-packages/configuring-nuget-behavior.md). Remove the package source in the files by editing them manually or using the [nuget sources command](../reference/nuget-exe-CLI-reference.md).
137
+
1. To manage NuGet package sources, see [NuGet Options in Visual Studio](nuget-visual-studio-options.md#package-sources).
Copy file name to clipboardExpand all lines: docs/consume-packages/managing-the-global-packages-and-cache-folders.md
+19-2Lines changed: 19 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,10 +70,13 @@ info : global-packages: /home/user1/.nuget/packages/
70
70
info : temp: /tmp/NuGetScratchuser1
71
71
info : plugins-cache: /home/user1/.local/share/NuGet/plugins-cache
72
72
```
73
+
73
74
To display the location of a single folder, use `http-cache`, `global-packages`, `temp`, or `plugins-cache` instead of `all`.
74
75
75
76
## Clearing local folders
76
77
78
+
### Command-line
79
+
77
80
If you encounter package installation problems or otherwise want to ensure that you're installing packages from a remote gallery, use the `locals --clear` option (dotnet.exe) or `locals -clear` (nuget.exe), specifying the folder to clear, or `all` to clear all folders:
78
81
79
82
```cli
@@ -103,9 +106,23 @@ nuget locals all -clear
103
106
104
107
Any packages used by projects that are currently open in Visual Studio are not cleared from the *global-packages* folder.
105
108
106
-
Starting in Visual Studio 2017, use the **Tools > NuGet Package Manager > Package Manager Settings** menu command, then select **Clear All NuGet Cache(s)**. Managing the cache isn't presently available through the Package Manager Console. In Visual Studio 2015, use the CLI commands instead.
109
+
### Visual Studio
110
+
111
+
Visual Studio supports clearing all local folders in the "NuGet Package Manager" options found under the **Tools > NuGet Package Manager > Package Manager Settings** menu command.
112
+
113
+
On the General page, select **Clear NuGet local resources**.
114
+
Once started, this action cannot be cancelled.
115
+
A progress bar will be shown and will contain the final status of the command.
116
+
117
+
The [Output Window](/visualstudio/ide/output-window) when selecting Show output from "Package Manager" will show additional details about the clear command, including any error messages.
118
+
119
+
### Clear NuGet Local Resources
120
+
121
+

122
+
123
+
Managing the cache isn't presently available through the Package Manager Console.
107
124
108
-

125
+
For more information, see [NuGet Options in Visual Studio](nuget-visual-studio-options.md#clear-nuget-local-resources).
0 commit comments