Skip to content

Commit 09c2acf

Browse files
committed
Feedback
1 parent 6f32e07 commit 09c2acf

File tree

3 files changed

+35
-35
lines changed

3 files changed

+35
-35
lines changed

docs/concepts/Auditing-Packages.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ If security vulnerabilities are found and updates are available for the package,
160160
If a known vulnerability exists in a top-level package's transitive dependencies, you have these options:
161161

162162
- Add the fixed package version as a direct package reference. **Note:** Be sure to remove this reference when a new package version update becomes available and be sure to maintain the defined attributes for the expected behavior.
163-
- Use [Central Package Management with the transitive pinning functionality](../consume-packages/Central-Package-Management.md#pinning-transitive-packages-to-different-versions).
163+
- Use [Central Package Management with the transitive pinning functionality](../consume-packages/Central-Package-Management.md#transitive-pinning).
164164
- [Suppress the advisory](#excluding-advisories) until it can be addressed.
165165
- File an issue in the top-level package's tracker to request an update.
166166

docs/consume-packages/Central-Package-Management.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -72,38 +72,6 @@ The version will be resolved from the corresponding `<PackageVersion />` entry i
7272

7373
Now you're using Central Package Management and managing your versions in a central location!
7474

75-
### Using Different Versions for Different Target Frameworks
76-
77-
As NuGet packages evolve, package owners may drop support for older target frameworks.
78-
This can cause issues for developers of libraries that still target older frameworks but want to reference newer versions of packages for newer target frameworks.
79-
80-
For example, if your project targets .NET Standard 2.0, .NET 8.0, and .NET Framework 4.7.2, but `PackageA` no longer supports .NET Standard 2.0 in its latest version, you can specify different versions for each target framework.
81-
82-
```xml
83-
<Project Sdk="Microsoft.NET.Sdk">
84-
<PropertyGroup>
85-
<TargetFrameworks>netstandard2.0;net8.0;net472</TargetFrameworks>
86-
</PropertyGroup>
87-
<ItemGroup>
88-
<PackageReference Include="PackageA" />
89-
</ItemGroup>
90-
</Project>
91-
```
92-
93-
In this case, define different versions for each target framework in your `Directory.Packages.props` using [MSBuild conditions](/visualstudio/msbuild/msbuild-conditions):
94-
95-
```xml
96-
<Project>
97-
<PropertyGroup>
98-
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
99-
</PropertyGroup>
100-
<ItemGroup>
101-
<PackageVersion Include="PackageA" Version="1.0.0" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
102-
<PackageVersion Include="PackageA" Version="2.0.0" Condition="'$(TargetFramework)' == 'net8.0' Or '$(TargetFramework)' == 'net472'" />
103-
</ItemGroup>
104-
</Project>
105-
```
106-
10775
## Central Package Management Rules
10876

10977
The `Directory.Packages.props` file has specific rules regarding its location and context within a repository.
@@ -157,7 +125,39 @@ To fully onboard your repository, follow these steps:
157125

158126
For an example of how Central Package Management may look, refer to our [samples repository](https://github.com/NuGet/Samples/tree/main/CentralPackageManagementExample).
159127

160-
## Pinning Transitive Packages to Different Versions
128+
## Using Different Versions for Different Target Frameworks
129+
130+
As NuGet packages evolve, package owners may drop support for older target frameworks.
131+
This can cause issues for developers of libraries that still target older frameworks but want to reference newer versions of packages for newer target frameworks.
132+
133+
For example, if your project targets .NET Standard 2.0, .NET 8.0, and .NET Framework 4.7.2, but `PackageA` no longer supports .NET Standard 2.0 in its latest version, you can specify different versions for each target framework.
134+
135+
```xml
136+
<Project Sdk="Microsoft.NET.Sdk">
137+
<PropertyGroup>
138+
<TargetFrameworks>netstandard2.0;net8.0;net472</TargetFrameworks>
139+
</PropertyGroup>
140+
<ItemGroup>
141+
<PackageReference Include="PackageA" />
142+
</ItemGroup>
143+
</Project>
144+
```
145+
146+
In this case, define different versions for each target framework in your `Directory.Packages.props` using [MSBuild conditions](/visualstudio/msbuild/msbuild-conditions):
147+
148+
```xml
149+
<Project>
150+
<PropertyGroup>
151+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
152+
</PropertyGroup>
153+
<ItemGroup>
154+
<PackageVersion Include="PackageA" Version="1.0.0" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
155+
<PackageVersion Include="PackageA" Version="2.0.0" Condition="'$(TargetFramework)' == 'net8.0' Or '$(TargetFramework)' == 'net472'" />
156+
</ItemGroup>
157+
</Project>
158+
```
159+
160+
## Transitive Pinning
161161

162162
You can automatically override a transitive package version without an explicit top-level `<PackageReference />` item by opting into a feature known as transitive pinning.
163163
This promotes a transitive dependency to a top-level dependency implicitly on your behalf when necessary.

docs/reference/errors-and-warnings/NU1011.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The use of floating versions introduces the possibility for a bad package to be
2828
This can lead to a situation where you made no changes in your repository but suddenly something is broken due to a problem in a new package and there is no way for you to get back into a good state without removing the floating version or pushing a newer version of the package which is fixed.
2929
Using non-floating versions means that every upgrade to a package is backed by a commit in your repository, making it easy to determine what change caused the break and allows you to revert a commit to get back into a good state.
3030

31-
Also, when using the [transitive pinning](../../consume-packages/Central-Package-Management.md#pinning-transitive-packages-to-different-versions) feature of [Central Package Management](../../consume-packages/Central-Package-Management.md), using a floating version as an override could make restores of different projects end up with different versions for the package that what is supposed to be pinned, thus going against the promise of using the centrally defined version.
31+
Also, when using the [transitive pinning](../../consume-packages/Central-Package-Management.md#transitive-pinning) feature of [Central Package Management](../../consume-packages/Central-Package-Management.md), using a floating version as an override could make restores of different projects end up with different versions for the package that what is supposed to be pinned, thus going against the promise of using the centrally defined version.
3232

3333
NuGet recommends you use automation like [Dependabot](https://docs.github.com/code-security/dependabot/working-with-dependabot) to keep package versions up-to-date which provides
3434
a streamlined way of updating package versions while integrating into your existing developer workflow of a pull request, automated build validation, and testing all backed by a commit in your repository.

0 commit comments

Comments
 (0)