Skip to content

Tolerate duplication in p2p negotiation batches#11878

Merged
YuliiaKovalova merged 1 commit into
dotnet:mainfrom
rainersigwald:allow-redundant-projrefs-in-negotiation
Oct 27, 2025
Merged

Tolerate duplication in p2p negotiation batches#11878
YuliiaKovalova merged 1 commit into
dotnet:mainfrom
rainersigwald:allow-redundant-projrefs-in-negotiation

Conversation

@rainersigwald

@rainersigwald rainersigwald commented May 21, 2025

Copy link
Copy Markdown
Member

The intent of batching over the condition

    '@(ProjectsWithNearestPlatform)' == '%(Identity)'

is to run the update for each item in the list (that meets the rest of
the condition).

However, if there are two list entries with identical %(Identity)--in
this case duplicate ProjectReferences--they batch into the same bucket
and then that condition is false.

Instead, batch over unique identities to tolerate duplicates.

Fixes #2688.

The intent of batching over the condition
    '@(ProjectsWithNearestPlatform)' == '%(Identity)'
is to run the update for each item in the list (that meets the rest of
the condition).

However, if there are two list entries with identical `%(Identity)`--in
this case duplicate ProjectReferences--they batch into the same bucket
and then that condition is `false`.

Instead, batch over unique identities to tolerate duplicates.

Fixes dotnet#2688.

Co-Authored-By: Benjamin Witman <[email protected]>
Copilot AI review requested due to automatic review settings May 21, 2025 20:54

Copilot AI left a comment

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.

Pull Request Overview

This PR updates MSBuild batching logic to process each project reference individually, tolerating duplicates by switching from list-based to metadata-based conditions.

  • Switched <ProjectsWithNearestPlatform> conditions to use %(Identity) metadata checks instead of comparing the entire item list.
  • Updated <AnnotatedProjects> conditions similarly for NearestTargetFramework, single-target checks, and RID agnosticism.

Comment thread src/Tasks/Microsoft.Common.CurrentVersion.targets
Comment thread src/Tasks/Microsoft.Common.CurrentVersion.targets
Comment thread src/Tasks/Microsoft.Common.CurrentVersion.targets
Comment thread src/Tasks/Microsoft.Common.CurrentVersion.targets
Comment thread src/Tasks/Microsoft.Common.CurrentVersion.targets
Comment thread src/Tasks/Microsoft.Common.CurrentVersion.targets
@YuliiaKovalova YuliiaKovalova self-requested a review June 2, 2025 14:51
@ghost ghost requested a review from SimaTian July 7, 2025 14:18
@ghost ghost assigned rainersigwald Jul 7, 2025
@baronfel baronfel requested a review from a team October 17, 2025 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failure in project reference target framework negotiation when ProjectReference items are duplicated

3 participants