Skip to content

Fix Pack project-version item collision - #7952

Closed
baronfel wants to merge 2 commits into
release/11.0.1xx-preview7from
baronfel-fix-pack-item-collision
Closed

baronfel wants to merge 2 commits into
release/11.0.1xx-preview7from
baronfel-fix-pack-item-collision

Conversation

@baronfel

@baronfel baronfel commented Jul 24, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Restore the Pack-target evaluation reuse introduced by NuGet.Client #7541, including the conditional NoBuild=true handling.
  • Rename _GetProjectVersion's private output item from _ProjectPathWithVersion to _ProjectReferenceWithVersion.
  • Restore the associated include-source test expectation.

Root cause

VMR build 1524269 and dotnet/dotnet #7907 failed while packing ASP.NET Core with An item with the same key has already been added.

NuGet.Client #7541 removed BuildProjectReferences=false from Pack's inner MSBuild calls so already-built project instances could be reused instead of redundantly evaluated. That reuse exposed an accidental private-item overlap: both NuGet Pack and ASP.NET Core used _ProjectPathWithVersion. The assets-file task returned unique project paths, but _GetProjectVersion returned the accumulated colliding items from the reused instances, and PackTask failed while creating its project-version dictionary.

NuGet.Client #7593 reverted the evaluation-reuse change to unblock the VMR. This change restores that behavior while giving NuGet's target output the unique _ProjectReferenceWithVersion name. Consumer-owned _ProjectPathWithVersion items can therefore remain on reused project instances without contaminating Pack's project-reference version outputs.

Validation

Targeted Dotnet.Integration.Test Pack coverage on net10.0: 6 passed

  • PackCommand_PackProject_GetsProjectRefVersionFromMsbuild (4 cases)
  • PackCommand_IncludeSource_AddsSourceFiles (2 cases)

Restore Pack evaluation reuse while isolating _GetProjectVersion outputs from consumer-owned _ProjectPathWithVersion items. Add regression coverage for reused project instances and restore the include-source expectation.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: ad2aed8e-36d1-4962-ba0c-f9fb24063054
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service
dotnet-policy-service Bot requested a review from a team July 24, 2026 21:27
The renamed private output item makes the injected old-name collision scenario no longer useful as direct regression coverage.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: ad2aed8e-36d1-4962-ba0c-f9fb24063054
@baronfel

Copy link
Copy Markdown
Member Author

cc @nkolev92, @zivkan for thoughts on this :)

@baronfel
baronfel marked this pull request as ready for review July 25, 2026 17:38
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@nkolev92 nkolev92 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.

LGTM. There's some unnecessary changes in the tests.


_dotnetFixture.CreateDotnetNewProject(testDirectory.Path, projectName, args: "classlib", testOutputHelper: _testOutputHelper);
_dotnetFixture.CreateDotnetNewProject(testDirectory.Path, referencedProject, "classlib", testOutputHelper: _testOutputHelper);
_dotnetFixture.CreateDotnetNewProject(

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.

This is just indentation.

@baronfel

Copy link
Copy Markdown
Member Author

Probably too late for p7, so I've re-done this over at NuGet.Client's dev branch for codeflow to rc1.

@baronfel baronfel closed this Jul 30, 2026
@dotnet-policy-service
dotnet-policy-service Bot requested a review from a team July 30, 2026 20:04
@akoeplinger
akoeplinger deleted the baronfel-fix-pack-item-collision branch August 11, 2026 16:45
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.

3 participants