Skip to content

Commit 521e509

Browse files
authored
Create Visual Studio Options Documentation (#3482)
1 parent e1caa83 commit 521e509

21 files changed

+196
-47
lines changed

docs/TOC.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
### [nuget.exe CLI](consume-packages/install-use-packages-nuget-cli.md)
1818
### [Package Manager Console (PowerShell)](consume-packages/install-use-packages-powershell.md)
1919
## Configure NuGet
20+
### [Visual Studio options](consume-packages/nuget-visual-studio-options.md)
2021
### Package restore options
2122
#### [Restore packages](consume-packages/package-restore.md)
2223
#### [Troubleshooting](consume-packages/package-restore-troubleshooting.md)

docs/consume-packages/Package-Source-Mapping.md

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ author: nkolev92
55
ms.author: nikolev
66
ms.date: 10/18/2023
77
ms.topic: conceptual
8-
f1_keywords:
9-
- "vs.toolsoptionspages.nuget_package_manager.package_source_mapping"
108
---
119

1210
# Package Source Mapping
@@ -21,6 +19,7 @@ We also have suggestions for other [best practices](..\concepts\Security-Best-Pr
2119

2220
Package Source Mapping was added in [NuGet 6.0](..\release-notes\NuGet-6.0.md).
2321
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).
2423

2524
### Visual Studio support
2625

@@ -55,34 +54,23 @@ To opt into this feature, you must have a `nuget.config` file. Having a single `
5554

5655
_From the Package Manager UI_
5756

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.
6059

6160
![The NuGet Package Manager window in Visual Studio showing a selected package, and a highlight around the "Package source mapping is off" status with a `Configure` button.](media/packageSourceMapping_PMUI_Status_Off_Annotated.png)
6261

6362
_From the Visual Studio Options Dialog_
6463

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.
6766

68-
![The Visual Studio `Package Source Mappings` Options Dialog showing no package source mappings, with an `Add` button to create a new mapping.](media/packageSourceMapping_VSOptions_NoMappings.png)
67+
For details about managing NuGet package source mappings, see [NuGet Options in Visual Studio](nuget-visual-studio-options.md#package-source-mapping).
6968

70-
3. Press the `Add` button in the `Package Source Mappings` page to open the `Add Package Source Mappings` dialog.
71-
72-
![The `Add Package Source Mappings` dialog](media/packageSourceMapping_VSOptions_AddMappingOpened.png)
73-
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-
![The `Add Package Source Mappings` dialog with a filled package pattern and selected package source.](media/packageSourceMapping_VSOptions_AddMappingFilled.png)
76-
77-
5. The `Package Source Mapping` options page will show the newly created source mapping.
78-
79-
![The `Package Source Mapping` options page showing the newly created source mapping](media/packageSourceMapping_VSOptions_AddMappingCompleted.png)
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.
8370
![The NuGet Package Manager window in Visual Studio showing a selected package with the "Package source mapping found" status with a `Configure` button.](media/packageSourceMapping_PMUI_Status_Mapped.png)
8471

8572
### Enable by manually editing `nuget.config`
73+
8674
* Declare your desired package sources in your `nuget.config` file.
8775
* Following your source declarations, add a `<packageSourceMapping>` element that specifies the desired mappings for each source.
8876
* 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
124112

125113
### Package Pattern requirements
126114

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.
128116

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.
130118
* 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.
131119

132120
### Package Pattern Syntax
@@ -165,7 +153,7 @@ For manual onboarding you may take the following steps:
165153
1. Run [dotnet restore](/dotnet/core/tools/dotnet-restore) to restore dependencies.
166154
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.
167155
* 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.
169157
1. Run [dotnet nuget locals global-packages -c](/dotnet/core/tools/dotnet-nuget-locals) to clear global-packages directory.
170158
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.
171159
1. When restore succeeds, you are done! Optionally consider:
@@ -174,7 +162,7 @@ For manual onboarding you may take the following steps:
174162

175163
#### Automated onboarding using tool
176164

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.
178166

179167
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.
180168

@@ -183,6 +171,7 @@ Tool has several option how to generate mapping pattern depending on your need,
183171
For an idea of how your source mappings may look like, refer to our [samples repo](https://github.com/NuGet/Samples/tree/main/PackageSourceMappingExample).
184172

185173
> [!Note]
174+
>
186175
> * 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).
187176
> * There are no means of mapping packages at package installation time, see [NuGet/Home#10730](https://github.com/NuGet/Home/issues/10730).
188177
> * 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).

docs/consume-packages/install-use-packages-visual-studio.md

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ ms.author: jodou
66
ms.date: 03/03/2025
77
ms.topic: conceptual
88
f1_keywords:
9-
- "vs.toolsoptionspages.nuget_package_manager"
10-
- "vs.toolsoptionspages.nuget_package_manager.general"
11-
- "vs.toolsoptionspages.nuget_package_manager.package_sources"
129
- "vs.nuget.packagemanager.ui"
1310
---
1411

@@ -48,7 +45,7 @@ To find and install a NuGet package with Visual Studio, follow these steps:
4845
> In Visual Studio 17.11 and higher, package owners are shown as profile hyperlinks when supported by the selected package source.
4946
> 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).
5047
>
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.
5249
> For more information, see [Authors package metadata](../create-packages/package-authoring-best-practices.md#authors).
5350

5451
- 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
129126

130127
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).
131128

132-
To manage NuGet package sources, follow these steps:
133-
134129
1. To change the source from which Visual Studio loads package metadata, select a source from the **Package source** selector.
135130

136131
![Screenshot showing the Package source selector highlighted.](media/package-source-selector.png)
@@ -139,21 +134,7 @@ To manage NuGet package sources, follow these steps:
139134

140135
![Screenshot showing the Package source settings icon highlighted.](media/package-source-settings.png)
141136

142-
1. In the **Options** window, expand the **NuGet Package Manager** node and select **Package Sources**.
143-
144-
![Screenshot showing the Options window with Package Sources selected.](media/package-sources.png)
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).
157138

158139
## NuGet Package Manager Options control
159140

docs/consume-packages/managing-the-global-packages-and-cache-folders.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,13 @@ info : global-packages: /home/user1/.nuget/packages/
7070
info : temp: /tmp/NuGetScratchuser1
7171
info : plugins-cache: /home/user1/.local/share/NuGet/plugins-cache
7272
```
73+
7374
To display the location of a single folder, use `http-cache`, `global-packages`, `temp`, or `plugins-cache` instead of `all`.
7475

7576
## Clearing local folders
7677

78+
### Command-line
79+
7780
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:
7881

7982
```cli
@@ -103,9 +106,23 @@ nuget locals all -clear
103106

104107
Any packages used by projects that are currently open in Visual Studio are not cleared from the *global-packages* folder.
105108

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+
![Clear NuGet local resources button highlighted in the General page of NuGet options](media/vsoptions/general.png)
122+
123+
Managing the cache isn't presently available through the Package Manager Console.
107124

108-
![NuGet option command for clearing caches](media/options-clear-caches.png)
125+
For more information, see [NuGet Options in Visual Studio](nuget-visual-studio-options.md#clear-nuget-local-resources).
109126

110127
## Troubleshooting errors
111128

-20.6 KB
Binary file not shown.
-24.7 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)