Skip to content

Commit 4f07b25

Browse files
committed
cleanup
1 parent 28033ad commit 4f07b25

6 files changed

Lines changed: 81 additions & 58 deletions

File tree

docs/TOC.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
### [PackageDownload functionality](consume-packages/packagedownload-functionality.md)
3333
## Reference packages in your project
3434
### [PackageReference in project files](consume-packages/package-references-in-project-files.md)
35+
### [Targeting multiple frameworks in a project file](consume-packages/package-reference-multi-targeting.md)
3536
### [Migrate packages.config to PackageReference](consume-packages/migrate-packages-config-to-package-reference.md)
3637
### [packages.config](reference/packages-config.md)
3738
### [Central Package Management](consume-packages/Central-Package-Management.md)

docs/consume-packages/Package-References-in-Project-Files.md

Lines changed: 76 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,82 @@ Note that because `build` is not included with `PrivateAssets`, targets and prop
142142
> [!NOTE]
143143
> When `developmentDependency` is set to `true` in a `.nuspec` file, this marks a package as a development-only dependency, which prevents the package from being included as a dependency in other packages. With PackageReference *(NuGet 4.8+)*, this flag also means that it will exclude compile-time assets from compilation. For more information, see [DevelopmentDependency support for PackageReference](https://github.com/NuGet/Home/wiki/DevelopmentDependency-support-for-PackageReference).
144144
145+
## Targeting multiple frameworks
146+
147+
SDK-style projects support multi-targeting by listing multiple values in the `TargetFrameworks` property. When a project targets multiple frameworks, NuGet restore produces a separate dependency graph for each framework, and `dotnet pack` creates a package with framework-specific assets for each target.
148+
149+
```xml
150+
<Project Sdk="Microsoft.NET.Sdk">
151+
<PropertyGroup>
152+
<TargetFrameworks>net10.0;netstandard2.0</TargetFrameworks>
153+
</PropertyGroup>
154+
</Project>
155+
```
156+
157+
For a step-by-step guide on setting up a multi-targeted project, see [Support multiple .NET frameworks in your project file](../create-packages/multiple-target-frameworks-project-file.md).
158+
159+
### How TargetFramework values work
160+
161+
The `TargetFramework` property in a project file is a friendly name — an alias — that gets translated into a canonical framework identity. The .NET SDK performs this translation by setting the `TargetFrameworkMoniker` (TFM), and when applicable, the `TargetPlatformMoniker` properties.
162+
163+
NuGet uses these moniker properties — not the `TargetFramework` string — for package compatibility checks. This means the `TargetFramework` value itself can be any string, as long as the moniker properties are set correctly.
164+
165+
For more details on the aliasing mechanism, see [TargetFramework values are aliases](../reference/target-frameworks.md#targetframework-values-are-aliases).
166+
167+
### Multi-targeting with duplicate frameworks
168+
169+
*This feature requires [NuGet 7.6](../release-notes/NuGet-7.6.md) / .NET SDK 10.0.300 or later.*
170+
171+
Because `TargetFramework` values are aliases, multiple aliases can resolve to the *same* effective framework. Starting with [NuGet 7.6](../release-notes/NuGet-7.6.md) / .NET SDK 10.0.300, NuGet and the .NET SDK support this scenario.
172+
173+
This enables use cases such as:
174+
175+
- **Multi-RID builds**: Build platform-specific assemblies from a single project.
176+
177+
```xml
178+
<Project Sdk="Microsoft.NET.Sdk">
179+
<PropertyGroup>
180+
<TargetFrameworks>apple;banana</TargetFrameworks>
181+
</PropertyGroup>
182+
183+
<PropertyGroup>
184+
<TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier>
185+
<TargetFrameworkVersion>v10.0</TargetFrameworkVersion>
186+
<TargetFrameworkMoniker>.NETCoreApp,Version=v10.0</TargetFrameworkMoniker>
187+
</PropertyGroup>
188+
</Project>
189+
```
190+
191+
- **Multi-version extensions**: Target multiple versions of a host application, such as Visual Studio.
192+
193+
```xml
194+
<Project Sdk="Microsoft.VisualStudio.Extensibility.Sdk">
195+
<PropertyGroup>
196+
<TargetFrameworks>vs18;vs17.14</TargetFrameworks>
197+
</PropertyGroup>
198+
</Project>
199+
```
200+
201+
In this example, the Visual Studio Extensibility SDK is responsible for setting the canonical moniker properties for each alias.
202+
203+
#### Pack
204+
205+
A NuGet package can only contain one set of build output and one dependency group per effective framework. When you pack a project with duplicate effective frameworks, you must tell NuGet which alias contributes these assets or the pack raises [NU5051](../reference/errors-and-warnings/NU5051.md). See [NU5051](../reference/errors-and-warnings/NU5051.md) for resolution steps and examples.
206+
207+
#### Lock file
208+
209+
When a project uses duplicate effective frameworks, the [packages lock file](#locking-dependencies) is automatically upgraded to a format that uses the alias as the key instead of the effective framework. This upgrade happens transparently — locked mode and CI/CD scenarios continue to work as before.
210+
211+
#### Project references
212+
213+
When a project references another project that has multiple aliases resolving to the same framework, NuGet uses the alias name as a tiebreaker. If the referencing project has an alias with the same name as one in the referenced project, that alias is preferred. If there’s no matching name and multiple candidates exist, NuGet reports an error.
214+
215+
#### Limitations
216+
217+
- Only SDK-style projects support duplicate effective frameworks.
218+
- Aliases that contain path separator characters (`/` or `\`) are blocked.
219+
- Visual Studio’s Package Manager UI doesn’t have special support for duplicate frameworks, but you can manage packages by editing the project file directly or using the `dotnet` CLI.
220+
145221
## Adding a PackageReference condition
146222

147223
You can use a condition to control whether a package is included. Conditions can use any MSBuild variable or a variable defined in the targets or props file. However, at present, only the `TargetFramework` variable is supported.
@@ -239,60 +315,6 @@ namespace PackageReferenceAliasesExample
239315

240316
```
241317

242-
## Multi-targeting with duplicate frameworks
243-
244-
*This feature requires [NuGet 7.6](../release-notes/NuGet-7.6.md) / .NET SDK 10.0.300 or later.*
245-
246-
SDK-style projects support [multi-targeting](../create-packages/multiple-target-frameworks-project-file.md) by listing multiple values in the `TargetFrameworks` property. Because [TargetFramework values are aliases](../reference/target-frameworks.md#targetframework-values-are-aliases), multiple aliases can resolve to the *same* effective framework. Starting with [NuGet 7.6](../release-notes/NuGet-7.6.md) / .NET SDK 10.0.300, NuGet and the .NET SDK support this scenario.
247-
248-
This enables use cases such as:
249-
250-
- **Multi-RID builds**: Build platform-specific assemblies from a single project.
251-
252-
```xml
253-
<Project Sdk="Microsoft.NET.Sdk">
254-
<PropertyGroup>
255-
<TargetFrameworks>apple;banana</TargetFrameworks>
256-
</PropertyGroup>
257-
258-
<PropertyGroup>
259-
<TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier>
260-
<TargetFrameworkVersion>v10.0</TargetFrameworkVersion>
261-
<TargetFrameworkMoniker>.NETCoreApp,Version=v10.0</TargetFrameworkMoniker>
262-
</PropertyGroup>
263-
</Project>
264-
```
265-
266-
- **Multi-version extensions**: Target multiple versions of a host application, such as Visual Studio.
267-
268-
```xml
269-
<Project Sdk="Microsoft.VisualStudio.Extensibility.Sdk">
270-
<PropertyGroup>
271-
<TargetFrameworks>vs18;vs17.14</TargetFrameworks>
272-
</PropertyGroup>
273-
</Project>
274-
```
275-
276-
In this example, the Visual Studio Extensibility SDK is responsible for setting the canonical moniker properties for each alias.
277-
278-
### Pack
279-
280-
A NuGet package can only contain one set of build output and one dependency group per effective framework. When you pack a project with duplicate effective frameworks, you must tell NuGet which alias contributes these assets or the pack raises [NU5051](../reference/errors-and-warnings/NU5051.md). See [NU5051](../reference/errors-and-warnings/NU5051.md) for resolution steps and examples.
281-
282-
### Lock file
283-
284-
When a project uses duplicate effective frameworks, the [packages lock file](#locking-dependencies) is automatically upgraded to a format that uses the alias as the key instead of the effective framework. This upgrade happens transparently — locked mode and CI/CD scenarios continue to work as before.
285-
286-
### Project references
287-
288-
When a project references another project that has multiple aliases resolving to the same framework, NuGet uses the alias name as a tiebreaker. If the referencing project has an alias with the same name as one in the referenced project, that alias is preferred. If there's no matching name and multiple candidates exist, NuGet reports an error.
289-
290-
### Limitations
291-
292-
- Only SDK-style projects support duplicate effective frameworks.
293-
- Aliases that contain path separator characters (`/` or `\`) are blocked.
294-
- Visual Studio's Package Manager UI doesn't have special support for duplicate frameworks, but you can manage packages by editing the project file directly or using the `dotnet` CLI.
295-
296318
## NuGet warnings and errors
297319

298320
*This feature is available with NuGet **4.3** or above and with Visual Studio 2017 **15.3** or above.*

docs/create-packages/multiple-target-frameworks-project-file.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Here is the *.csproj* file that is generated using the preceding steps and .NET
7070

7171
Starting with [NuGet 7.6](../release-notes/NuGet-7.6.md) / .NET SDK 10.0.300, you can use multiple `TargetFrameworks` values that resolve to the same underlying framework. This enables scenarios like building for multiple runtimes or targeting multiple versions of a host application from a single project.
7272

73-
For details on how this works with restore and pack, see [Multi-targeting with duplicate frameworks](../consume-packages/package-references-in-project-files.md#multi-targeting-with-duplicate-frameworks).
73+
For details on how this works with restore and pack, see [Targeting multiple frameworks](../consume-packages/package-references-in-project-files.md#multi-targeting-with-duplicate-frameworks).
7474

7575
## See also
7676

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,4 @@ Suppress the default build output and dependencies for the secondary aliases, an
9898

9999
With this configuration, `net10.0` contributes the default `lib/net10.0/` build output and dependencies, while `linux` and `ios` place their assemblies under `runtimes/linux/lib/net10.0/` and `runtimes/ios/lib/net10.0/` respectively.
100100

101-
For more information about multi-targeting with duplicate frameworks, see [PackageReference in project files](../../consume-packages/package-references-in-project-files.md#multi-targeting-with-duplicate-frameworks). For more information about pack extensibility, see [pack target](../msbuild-targets.md#pack-target).
101+
For more information about multi-targeting with duplicate frameworks, see [Targeting multiple frameworks](../../consume-packages/package-references-in-project-files.md#multi-targeting-with-duplicate-frameworks). For more information about pack extensibility, see [pack target](../msbuild-targets.md#pack-target).

docs/reference/target-frameworks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ This project restores and builds for .NET 10.0, even though the `TargetFramework
4747

4848
## Multi-targeting with duplicate frameworks
4949

50-
Starting with [NuGet 7.6](../release-notes/NuGet-7.6.md) / .NET SDK 10.0.300, multiple `TargetFrameworks` aliases can resolve to the same effective framework. This enables scenarios like multi-RID builds and multi-version extension targeting. For details on how this works with restore, pack, lock files, and project references, see [Multi-targeting with duplicate frameworks](../consume-packages/package-references-in-project-files.md#multi-targeting-with-duplicate-frameworks).
50+
Starting with [NuGet 7.6](../release-notes/NuGet-7.6.md) / .NET SDK 10.0.300, multiple `TargetFrameworks` aliases can resolve to the same effective framework. This enables scenarios like multi-RID builds and multi-version extension targeting. For details on how this works with restore, pack, lock files, and project references, see [Targeting multiple frameworks](../consume-packages/package-references-in-project-files.md#multi-targeting-with-duplicate-frameworks).
5151

5252
## Supported frameworks
5353

docs/release-notes/NuGet-7.5.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: NuGet 7.5 Release Notes
33
description: Release notes for NuGet 7.5 including new features, bug fixes, and DCRs.
44
author: nikolev
5-
ms.topic: conceptual
5+
ms.topic: release-notes
66
---
77
# NuGet 7.5 Release Notes
88

0 commit comments

Comments
 (0)