Skip to content

Pack is aliased framework aware and supports deduplication to allowed aliased projects to be packed. - #7227

Merged
nkolev92 merged 8 commits into
devfrom
dev-nkolev92-aliasedPack
Mar 24, 2026
Merged

nkolev92 merged 8 commits into
devfrom
dev-nkolev92-aliasedPack

Conversation

@nkolev92

@nkolev92 nkolev92 commented Mar 23, 2026 •

Copy link
Copy Markdown
Member

Bug

Fixes: NuGet/Home#14751
Fixes: NuGet/Home#14535

Description

Makes NuGet Pack aliased-framework-aware. When a project has multiple TFM aliases that resolve to the same NuGet framework (e.g., TargetFrameworks=apple;banana where both map to net10.0), pack now detects the ambiguity and raises NU5051 with an actionable error message instead of silently producing a broken package or crashing.

Users can resolve the ambiguity by setting per-alias MSBuild properties:

• IncludeBuildOutput=false — suppresses build output from the secondary alias
• SuppressDependenciesWhenPacking=true — suppresses dependency inclusion from the secondary alias

When both are set on all but one alias per effective framework, pack succeeds and produces a single lib group and a single dependency group for that framework. Framework references are also deduplicated — if all aliases for a framework declare identical FrameworkReference items, they're merged silently; if they differ, NU5051 is raised. People can suppress FrameworkReference with PrivateAssets="all". Im hesitant to add another mechanism similar to suppress dependencies when packing without more feedback.

Note that the deduplication is detected based on the where the files go, so if someone wants to make the build out from one leg go to the runtimes folder, but in the lib folder in another one, that should be now possible.

cc @ViktorHofer @ericstj I know you had feedback on the pack experience.

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc. Document NU5051 Home#14821

@nkolev92
nkolev92 marked this pull request as ready for review March 23, 2026 21:51
@nkolev92
nkolev92 requested a review from a team as a code owner March 23, 2026 21:51

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the .designer.cs file isn't supposed to be checked in. Most arcadified repos use the GenerateSource=true metadata on EmbeddedResource item integration to automatically create the file on build. Completely unrelated to this PR, just a side observation.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting. Is there a perf consideration there?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that I'm aware of. The task that creates it is optimized. It's also incremental build aware.

@nkolev92
nkolev92 enabled auto-merge (squash) March 24, 2026 20:17
@nkolev92
nkolev92 merged commit 279cdad into dev Mar 24, 2026
16 checks passed
@nkolev92
nkolev92 deleted the dev-nkolev92-aliasedPack branch March 24, 2026 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants