Skip to content

Fix pack-publish race in ApiCompat.Task / GenAPI.Task by deduplicating the Publish build - #54591

Merged
MichaelSimons merged 3 commits into
dotnet:mainfrom
dsplaisted:fix-genapi-apicompat-pack-publish-race
Jun 9, 2026
Merged

MichaelSimons merged 3 commits into
dotnet:mainfrom
dsplaisted:fix-genapi-apicompat-pack-publish-race

Conversation

@dsplaisted

Copy link
Copy Markdown
Member

PR #54567 did not eliminate, the intermittent "file in use" race (MSB3026/MSB3027) when packing these tooling packages. This is because TargetFramework is set as a global property when AddBuildOutputToPackageCore runs, so we still ended up having duplicate builds of the project.

Fix: run Publish via an task call with RemoveProperties="TargetFramework" so the request deduplicates with other builds of the project (since the global properties are the same).

…g the Publish configuration

PR dotnet#54567 did not eliminate, the intermittent "file in use" race (MSB3026/MSB3027)
when packing these tooling packages.  This is because TargetFramework is set
as a global property when AddBuildOutputToPackageCore runs, so we still ended
up having duplicate builds of the project.

Fix: run Publish via an <MSBuild> task call with RemoveProperties="TargetFramework"
so the request deduplicates with other builds of the project (since the global properties
are the same).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsplaisted
dsplaisted requested a review from a team as a code owner June 4, 2026 15:57
Copilot AI review requested due to automatic review settings June 4, 2026 15:57
@dsplaisted
dsplaisted requested a review from MichaelSimons June 4, 2026 15:57

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 addresses an intermittent MSBuild “file in use” race (MSB3026/MSB3027) during pack for Microsoft.DotNet.ApiCompat.Task and Microsoft.DotNet.GenAPI.Task by ensuring the Publish build request is deduplicated (removing TargetFramework from the MSBuild task’s global properties).

Changes:

  • Replace _AddBuildOutputToPackageCore’s DependsOnTargets="Publish" with an explicit <MSBuild Targets="Publish" RemoveProperties="TargetFramework" /> invocation.
  • Add inline comments explaining why TargetFramework must be removed to avoid duplicate builds during NuGet’s pack walk.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/Compatibility/GenAPI/Microsoft.DotNet.GenAPI.Task/Microsoft.DotNet.GenAPI.Task.csproj Invokes Publish via an MSBuild task with RemoveProperties="TargetFramework" to avoid duplicate pack-time builds.
src/Compatibility/ApiCompat/Microsoft.DotNet.ApiCompat.Task/Microsoft.DotNet.ApiCompat.Task.csproj Same deduplication approach for ApiCompat task publishing during pack.

@dsplaisted
dsplaisted requested a review from a team June 8, 2026 23:28
MichaelSimons and others added 2 commits June 9, 2026 07:34
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@MichaelSimons
MichaelSimons enabled auto-merge (squash) June 9, 2026 12:35
@MichaelSimons
MichaelSimons merged commit 58918b1 into dotnet:main Jun 9, 2026
25 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview6 milestone Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants