Repository navigation
fix(ci): kill the multi-arch publish CopyRefAssembly race (MSB3883) - #552
Merged
Merged
Conversation
The continuous/release/edge image builds publish per-RID via -p:ContainerRuntimeIdentifiers="linux-x64;linux-arm64", and the SDK builds the two RID legs CONCURRENTLY. A reference assembly is RID-invariant, so its intermediate path has no rid segment (obj/<cfg>/<tfm>/ref/<Asm>.dll) — both legs' CopyRefAssembly target write that same file and intermittently collide: 'error MSB3883: ... MeshWeaver.Graph.dll ... being used by another process', failing the portal-ai image build (e.g. CD run 29687305177). Root fix: turn off reference-assembly production for the multi-arch publish only (Directory.Build.props, gated on the global ContainerRuntimeIdentifiers being set — seen by every project in the publish graph, including the referenced libraries that race). Ref assemblies only accelerate INCREMENTAL rebuilds; a from-clean CI publish gains nothing, so this removes the one shared, contended output while keeping both RID legs parallel — no serialization, no retry. Normal dev + Build-and-Test CI leave ContainerRuntimeIdentifiers empty, so ref assemblies and fast incremental builds are unaffected there. Verified via -getProperty on MeshWeaver.Graph (the project that raced): ProduceReferenceAssembly evaluates true with no multi-arch prop, false when ContainerRuntimeIdentifiers is set. No user-facing change → no What's New entry. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses an intermittent CI/CD build-time flake in multi-arch container publishes where concurrent RID legs race on the same RID-invariant reference-assembly intermediate output (CopyRefAssembly → MSB3883). It does so by disabling reference-assembly generation only when ContainerRuntimeIdentifiers is set, preserving normal dev and non-container CI behavior.
Changes:
- Conditionally disables
ProduceReferenceAssemblywhen$(ContainerRuntimeIdentifiers)is non-empty to avoid concurrent writes toobj/<cfg>/<tfm>/ref/*.dllduring multi-RID container publish.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Contributor
Contributor
Contributor
Contributor
Contributor
Contributor
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.
The flake
The portal-ai image build intermittently fails the continuous deploy with:
(e.g. CD run 29687305177). This is a build-time race, not a runtime one — no hub / observable / cached-instance involved.
Root cause
The CD/release/edge image builds publish per-RID via
-p:ContainerRuntimeIdentifiers="linux-x64;linux-arm64", and the SDK builds the two RID legs concurrently. A reference assembly is RID-invariant, so its intermediate path has no rid segment —obj/<cfg>/<tfm>/ref/<Asm>.dll. Both RID legs'CopyRefAssemblytarget therefore write the same file and intermittently collide. It's non-deterministic because it only fails when the two legs happen to hitCopyRefAssemblyfor the same referenced library at the same instant.The fix
Turn off reference-assembly production for the multi-arch publish only, in
Directory.Build.props, gated on the globalContainerRuntimeIdentifiersbeing set (a global property, so it is seen by every project in the publish graph — including the referenced libraries that actually race).Reference assemblies only accelerate incremental rebuilds; a from-clean CI container publish gains nothing from them — so this removes the one shared, contended output while keeping both RID legs parallel (no serialization, no retry, no slowdown). Normal dev builds and the
Build and TestCI leaveContainerRuntimeIdentifiersempty, so ref assemblies and fast incremental builds are unaffected there. Coversmain-cd,release-images, andedge-imagesfrom one place — no per-command drift.Verification
Deterministically checked on
MeshWeaver.Graph(the project that raced), viadotnet msbuild -getProperty:ProduceReferenceAssembly:ProduceReferenceAssemblytrue(default — unchanged)-p:ContainerRuntimeIdentifiers=linux-x64%3Blinux-arm64(publish)false(racy artifact not produced)No user-facing change → no What's New entry.
🤖 Generated with Claude Code