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/Central-Package-Management.md
+41Lines changed: 41 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -122,6 +122,7 @@ For an idea of how central package management may look like, refer to our [sampl
122
122
123
123
You can automatically override a transitive package version even without an explicit top-level `<PackageReference />` by opting into a feature known as
124
124
transitive pinning. This promotes a transitive dependency to a top-level dependency implicitly on your behalf when necessary.
125
+
Note that downgrades are allowed when transitive pinning a package. If you attempt to pin a package to a lower version than the one requested by your dependencies, restore will raise a [NU1109](../reference/errors-and-warnings/NU1109.md) error.
125
126
126
127
You can enable this feature by setting the MSBuild property `CentralPackageTransitivePinningEnabled` to `true` in a project or in a `Directory.Packages.props`
127
128
or `Directory.Build.props` import file:
@@ -132,6 +133,45 @@ or `Directory.Build.props` import file:
132
133
</PropertyGroup>
133
134
```
134
135
136
+
### Transitive pinning and pack
137
+
138
+
When a package is transitively pinned, your project uses a higher than the one requested by your dependencies.
139
+
If you create a package from your project, in order to ensure that your package will work, NuGet will promote the transitively pinned dependencies to explicit dependencies in the nuspec.
140
+
141
+
In the following example, `PackageA 1.0.0` has a dependency on `PackageB 1.0.0`.
Because of this, the use of transitive pinning should be carefully evaluated when authoring a library as it may lead to dependencies you did not expect.
174
+
135
175
## Overriding package versions
136
176
137
177
You can override an individual package version by using the `VersionOverride` property on a `<PackageReference />` item. This overrides any `<PackageVersion />`
@@ -181,6 +221,7 @@ If you'd like to disable central package management for any a particular project
181
221
```
182
222
183
223
## Global Package References
224
+
184
225
> [!Note]
185
226
> This feature is only available in Visual Studio 2022 17.4 or higher, .NET SDK 7.0.100.preview7 or higher, and NuGet 6.4 or higher.
0 commit comments