Skip to content

Commit ab8146d

Browse files
authored
Correct the _nuget.config_ file, to include the outer XML. The XML declaration and the top-level configuration node. (#3162)
1 parent d42f55f commit ab8146d

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

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

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Package Source Mapping
33
description: Describes package source mapping functionality and how to onboard
44
author: nkolev92
55
ms.author: nikolev
6-
ms.date: 03/15/2022
6+
ms.date: 10/18/2023
77
ms.topic: conceptual
88
f1_keywords:
99
- "vs.toolsoptionspages.nuget_package_manager.package_source_mapping"
@@ -84,27 +84,31 @@ _From the Visual Studio Options Dialog_
8484
* Add as many patterns as you find necessary.
8585

8686
```xml
87-
<!-- Define the package sources, nuget.org and contoso.com. -->
88-
<!-- `clear` ensures no additional sources are inherited from another config file. -->
89-
<packageSources>
90-
<clear />
91-
<!-- `key` can be any identifier for your source. -->
92-
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
93-
<add key="contoso.com" value="https://contoso.com/packages/" />
94-
</packageSources>
95-
96-
<!-- Define mappings by adding package patterns beneath the target source. -->
97-
<!-- Contoso.* packages and NuGet.Common will be restored from contoso.com, everything else from nuget.org. -->
98-
<packageSourceMapping>
99-
<!-- key value for <packageSource> should match key values from <packageSources> element -->
100-
<packageSource key="nuget.org">
101-
<package pattern="*" />
102-
</packageSource>
103-
<packageSource key="contoso.com">
104-
<package pattern="Contoso.*" />
105-
<package pattern="NuGet.Common" />
106-
</packageSource>
107-
</packageSourceMapping>
87+
<?xml version="1.0" encoding="utf-8"?>
88+
<configuration>
89+
<!-- Define the package sources, nuget.org and contoso.com. -->
90+
<!-- `clear` ensures no additional sources are inherited from another config file. -->
91+
<packageSources>
92+
<clear />
93+
<!-- `key` can be any identifier for your source. -->
94+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
95+
<add key="contoso.com" value="https://contoso.com/packages/" />
96+
</packageSources>
97+
98+
<!-- Define mappings by adding package patterns beneath the target source. -->
99+
<!-- Contoso.* packages and NuGet.Common will be restored from contoso.com,
100+
everything else from nuget.org. -->
101+
<packageSourceMapping>
102+
<!-- key value for <packageSource> should match key values from <packageSources> element -->
103+
<packageSource key="nuget.org">
104+
<package pattern="*" />
105+
</packageSource>
106+
<packageSource key="contoso.com">
107+
<package pattern="Contoso.*" />
108+
<package pattern="NuGet.Common" />
109+
</packageSource>
110+
</packageSourceMapping>
111+
</configuration>
108112
```
109113

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

0 commit comments

Comments
 (0)