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/Package-References-in-Project-Files.md
+58-54Lines changed: 58 additions & 54 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -164,60 +164,6 @@ NuGet uses these moniker properties — not the `TargetFramework` string — for
164
164
165
165
For more details on the aliasing mechanism, see [TargetFramework values are aliases](../reference/target-frameworks.md#targetframework-values-are-aliases).
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.
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
-
221
167
## Adding a PackageReference condition
222
168
223
169
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.
@@ -408,6 +354,8 @@ In order to persist the full closure of package dependencies, you can opt-in to
408
354
409
355
If this property is set, NuGet restore will generate a lock file (`packages.lock.json`) at the project root directory that lists all the package dependencies.
410
356
357
+
The `packages.lock.json` has a versioned format. Depending on the features you have enabled, such as Central Package Management and transitive pinning, or whether you use a duplicate effective target framework you may get a different version.
358
+
411
359
> [!Note]
412
360
> Once a project has `packages.lock.json` file in its root directory, the lock file is always used with restore even if the property `RestorePackagesWithLockFile` is not set. So another way to opt-in to this feature is to create a dummy blank `packages.lock.json` file in the project's root directory.
413
361
@@ -547,6 +495,62 @@ You can leave off `$(AssetTargetFallback)` if you wish to overwrite, instead of
547
495
>
548
496
> `$(PackageTargetFallback)` was an earlier feature that attempted to address this challenge, but it is fundamentally broken and *should* not be used. To migrate from `$(PackageTargetFallback)` to `$(AssetTargetFallback)`, simply change the property name.
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.
503
+
504
+
This enables use cases such as:
505
+
506
+
-**Multi-RID builds**: Build platform-specific assemblies from a single project.
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.
543
+
544
+
#### Project references
545
+
546
+
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.
547
+
548
+
#### Limitations
549
+
550
+
- Only SDK-style projects support duplicate effective frameworks.
551
+
- Aliases that contain path separator characters (`/` or `\`) are blocked.
552
+
- 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.
553
+
550
554
## PrunePackageReference
551
555
552
556
The .NET Runtime is constantly evolving, with performance improvements and new APIs each release.
0 commit comments