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/concepts/Auditing-Packages.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -160,7 +160,7 @@ If security vulnerabilities are found and updates are available for the package,
160
160
If a known vulnerability exists in a top-level package's transitive dependencies, you have these options:
161
161
162
162
- 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).
164
164
-[Suppress the advisory](#excluding-advisories) until it can be addressed.
165
165
- File an issue in the top-level package's tracker to request an update.
Copy file name to clipboardExpand all lines: docs/consume-packages/Central-Package-Management.md
+33-33Lines changed: 33 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,38 +72,6 @@ The version will be resolved from the corresponding `<PackageVersion />` entry i
72
72
73
73
Now you're using Central Package Management and managing your versions in a central location!
74
74
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.
In this case, define different versions for each target framework in your `Directory.Packages.props` using [MSBuild conditions](/visualstudio/msbuild/msbuild-conditions):
<PackageVersionInclude="PackageA"Version="2.0.0"Condition="'$(TargetFramework)' == 'net8.0' Or '$(TargetFramework)' == 'net472'" />
103
-
</ItemGroup>
104
-
</Project>
105
-
```
106
-
107
75
## Central Package Management Rules
108
76
109
77
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:
157
125
158
126
For an example of how Central Package Management may look, refer to our [samples repository](https://github.com/NuGet/Samples/tree/main/CentralPackageManagementExample).
159
127
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.
In this case, define different versions for each target framework in your `Directory.Packages.props` using [MSBuild conditions](/visualstudio/msbuild/msbuild-conditions):
<PackageVersionInclude="PackageA"Version="2.0.0"Condition="'$(TargetFramework)' == 'net8.0' Or '$(TargetFramework)' == 'net472'" />
156
+
</ItemGroup>
157
+
</Project>
158
+
```
159
+
160
+
## Transitive Pinning
161
161
162
162
You can automatically override a transitive package version without an explicit top-level `<PackageReference />` item by opting into a feature known as transitive pinning.
163
163
This promotes a transitive dependency to a top-level dependency implicitly on your behalf when necessary.
Copy file name to clipboardExpand all lines: docs/reference/errors-and-warnings/NU1011.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ The use of floating versions introduces the possibility for a bad package to be
28
28
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.
29
29
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.
30
30
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.
32
32
33
33
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
34
34
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