Skip to content

Commit 675ce51

Browse files
authored
Package Source Mapping: Installing with Package Manager UI (#3519)
1 parent 556a7c5 commit 675ce51

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ For detailed information on all Visual Studio NuGet options, see [NuGet Options
2828
| 17.0 - 17.4 | ✅ Available | ❌ Not available | ❌ Not available |
2929
| 17.5 | ✅ Available | ✅ Available | ❌ Not available |
3030
| 17.7 Preview 3| ✅ Available | ✅ Available | ✅ Status displayed |
31+
| 17.8 | ✅ Available | ✅ Available |[PackageReference automatically creates mappings](#installing-with-package-manager-ui)|
3132

3233
The feature is available across all NuGet integrated tooling.
3334

@@ -106,6 +107,34 @@ The NuGet Package Manager window will refresh and reflect the new status of the
106107

107108
Package Source Mapping settings are applied following [nuget.config precedence rules](configuring-nuget-behavior.md#how-settings-are-applied) when multiple `nuget.config` files at various levels (machine-level, user-level, repo-level) are present.
108109

110+
## Installing with Package Manager UI
111+
112+
As of Visual Studio 17.8 or newer, when the criteria below is met, Package Manager UI will attempt to automatically create package source mappings for the package IDs being installed (the top-level and dependent packages), when using the package Install or Update features.
113+
114+
The following message will be shown when the criteria for this to happen automatically is met:
115+
116+
> A package source mapping will be created.
117+
118+
Currently, creating source mappings is automatic only when:
119+
120+
- The project is using PackageReference.
121+
- Package source mapping is already enabled (you've added a mapping already, or created a section in your NuGet.Config).
122+
- A single package source is selected in the dropdown (that is, selecting "All" for package sources is not supported as it is ambiguous which source should be mapped).
123+
124+
![The Newtonsoft.Json package is selected in Package Manager UI and the message "A package source mapping will be created." is shown. The "Show preview window" option is checked.](./media/package-source-mapping-auto.png)
125+
126+
The operation may fail with [NU1110](../../docs/reference/errors-and-warnings/NU1110.md) if it's found that a dependency in your Global Packages Folder came from a package source that isn't enabled in your current solution.
127+
See the error code documentation for ways to resolve this problem.
128+
129+
Selecting the "Show preview window" option will list the new package source mappings being created.
130+
131+
If the preview is not what you want for the source mappings, cancel the install and configure the relevant source mappings manually prior to performing the Install/Update.
132+
133+
For example, installing the package `Polly` results in both `Polly` and its dependency `Polly.Core` being automatically source mapped to the selected package source, nuget.org.
134+
Microsoft dependent packages are being installed using existing package source mappings.
135+
136+
![Preview changes window showing a Solution section with "Creating source mappings to 'nuget.org': Polly, Polly.Core" with an Apply, Copy, and Cancel button.](./media/package-source-mapping-preview.png)
137+
109138
## Package Source Mapping rules
110139

111140
For maximum flexibility and control, NuGet requires that all packages match a package pattern through a well defined precedence.
38.2 KB
Loading
12 KB
Loading

0 commit comments

Comments
 (0)