Skip to content

Fix Gateway publish race with concurrent top-level build - #68069

Merged
akoeplinger merged 2 commits into
dotnet:mainfrom
wtgodbe:wtgodbe/fix-gateway-publish-race
Jul 28, 2026
Merged

akoeplinger merged 2 commits into
dotnet:mainfrom
wtgodbe:wtgodbe/fix-gateway-publish-race

Conversation

@wtgodbe

@wtgodbe wtgodbe commented Jul 28, 2026

Copy link
Copy Markdown
Member

Description

Microsoft.AspNetCore.Components.Gateway.Cli.csproj's _PublishGatewayForTool target ran a nested <MSBuild Targets="Publish"> call against Gateway.csproj with an explicit Configuration/TargetFramework override. Gateway.csproj also ships its own package and is built directly as a top-level project elsewhere in the overall build.

Forcing TargetFramework on the nested call gave that MSBuild request a global property that the other, independent build of Gateway.csproj doesn't have. Since MSBuild identifies a project build request by its project path + global properties, this made MSBuild treat the two as distinct, unrelated build instances rather than deduplicating/serializing them. Both ran concurrently and raced to write the same compressed static web asset output files under artifacts/obj/.../compressed/publish/, causing an intermittent file-lock error during unified build (VMR) publishing.

Gateway.csproj is single-targeted, so no override is needed here: dropping the explicit Properties lets this request's global properties match the other invocation's, so MSBuild recognizes it as the same build request and reuses/waits for its result instead of duplicating the build.

Fixes dotnet/dotnet#8005

Microsoft.AspNetCore.Components.Gateway.Cli.csproj's _PublishGatewayForTool
target ran a nested <MSBuild Targets="Publish"> call against Gateway.csproj
with an explicit Configuration/TargetFramework override. Gateway.csproj also
ships its own package and is built directly as a top-level project elsewhere
in the overall build. Forcing TargetFramework here gave this MSBuild request
a global property that the other invocation didn't have, so MSBuild treated
the two as distinct, unrelated build instances instead of deduplicating them.
Both ran concurrently and raced to write the same compressed static web asset
output files.

Gateway.csproj is single-targeted, so no override is needed: dropping the
explicit Properties lets this request's global properties match the other
invocation's, so MSBuild recognizes it as the same request and reuses/waits
for its result instead of duplicating the build.

Fixes dotnet/dotnet#8005

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings July 28, 2026 16:34
@wtgodbe
wtgodbe requested a review from a team as a code owner July 28, 2026 16:34

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 fixes an intermittent build/publish race in the Components Gateway tool packaging flow by ensuring a nested MSBuild publish of Gateway.csproj uses the same global property set as other top-level builds of the same project, allowing MSBuild to deduplicate/serialize the work instead of running two concurrent builds that contend on the same output files.

Changes:

  • Removed the explicit Configuration/TargetFramework override from the nested <MSBuild Targets="Publish"> invocation.
  • Added detailed inline documentation explaining why overriding TargetFramework caused MSBuild to treat the publish as a distinct build request (and how that led to the static web asset compression file-lock race).

@akoeplinger
akoeplinger requested review from javiercn and maraf July 28, 2026 16:40
@akoeplinger
akoeplinger enabled auto-merge (squash) July 28, 2026 17:54
@akoeplinger
akoeplinger merged commit 3aac446 into dotnet:main Jul 28, 2026
26 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-rc1 milestone Jul 29, 2026
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.

[Operational Issue]: Flaky file lock issue in Microsoft.AspNetCore.Components.Gateway

4 participants