Repository navigation
Fix Gateway publish race with concurrent top-level build - #68069
Merged
akoeplinger merged 2 commits intoJul 28, 2026
Merged
Conversation
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]>
Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
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/TargetFrameworkoverride from the nested<MSBuild Targets="Publish">invocation. - Added detailed inline documentation explaining why overriding
TargetFrameworkcaused MSBuild to treat the publish as a distinct build request (and how that led to the static web asset compression file-lock race).
akoeplinger
approved these changes
Jul 28, 2026
maraf
approved these changes
Jul 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Microsoft.AspNetCore.Components.Gateway.Cli.csproj's_PublishGatewayForTooltarget ran a nested<MSBuild Targets="Publish">call againstGateway.csprojwith an explicitConfiguration/TargetFrameworkoverride.Gateway.csprojalso ships its own package and is built directly as a top-level project elsewhere in the overall build.Forcing
TargetFrameworkon the nested call gave that MSBuild request a global property that the other, independent build ofGateway.csprojdoesn'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 underartifacts/obj/.../compressed/publish/, causing an intermittent file-lock error during unified build (VMR) publishing.Gateway.csprojis single-targeted, so no override is needed here: dropping the explicitPropertieslets 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