Repository navigation
Isolate MSBuild workers between DCP runs - #22638
Karol Zadora-Przylecki (karolz-ms) wants to merge 1 commit into
Conversation
Co-authored-by: Copilot App <[email protected]>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 22638Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 22638" |
Tests selector52 / 101 PR test projects · 4 PR jobs, from 10 changed files. Selected PR test projects (52 / 101)
Selected PR jobs (4)
How these were chosen — grouped by what changed
🔧 show 46
📦 affected project 🧪 📦 affected project 🧪 🧪 🧪 🧪 Job reasons
Selection computed for commit |
There was a problem hiding this comment.
🔵 Needs a closer look
The mitigation relies on undocumented MSBuild handshake and Windows job-lifetime behavior, while macOS checks cannot validate the reported Windows restart fix or representative warm-start cost.
No open issues 🎉
What changed in this PR
This PR isolates MSBuild worker reuse by DCP run to mitigate the suspected cross-run cleanup race behind Windows MSB4166 failures in #22560. The reported Windows restart scenario remains unvalidated.
Changes:
- Composes a per-run handshake salt for coordinated builds and rebuilders, preserving configured build properties, runtime environments, and IDE metadata.
- Registers composed salts for secret redaction and adds coverage for reuse boundaries, overrides, restarts, and publishing behavior.
- Documents the warm-start and idle-worker memory tradeoffs.
| File | Description |
|---|---|
| tests/Aspire.Hosting.Tests/Dcp/ExecutableLaunchPlanTests.cs | Tests salt composition, isolation, redaction, casing, and unaffected executables. |
| tests/Aspire.Hosting.Tests/Dcp/DcpHostNotificationTests.cs | Checks inherited salt initialization when DCP starts. |
| tests/Aspire.Hosting.Tests/Dcp/DcpExecutorTests.cs | Tests isolation on resource creation and restart. |
| tests/Aspire.Hosting.Dotnet.Tests/DotnetProjectBuildCoordinatorTests.cs | Verifies build isolation while preserving properties, metadata, runtime settings, and publishing. |
| tests/Aspire.Hosting.Blazor.Tests/AddBlazorGatewayTests.cs | Updates renderer calls for the new dependencies. |
| src/Aspire.Hosting/Lifecycle/DotnetBuildCommandEventingSubscriber.cs | Exposes the managed-build predicate for internal reuse. |
| src/Aspire.Hosting/DistributedApplicationBuilder.cs | Registers the DCP-owned isolation service. |
| src/Aspire.Hosting/Dcp/MsBuildNodeReuseIsolation.cs | Implements per-run salt composition and redaction registration. |
| src/Aspire.Hosting/Dcp/ExecutableCreator.cs | Applies isolation when rendering executable environments. |
| src/Aspire.Hosting/Dcp/DcpHost.cs | Initializes isolation before launching DCP. |
| src/Aspire.Hosting.Dotnet/README.md | Documents worker reuse boundaries and operational tradeoffs. |
Review effort: Balanced
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
There was a problem hiding this comment.
🔵 Needs a closer look
The mitigation relies on an undocumented MSBuild handshake, while the suspected Windows DCP cleanup race and warm-build impact remain unvalidated and require human runtime verification before shipping.
No open issues 🎉
Review effort: Max
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
4757cded3af081ad39cf12716cfda68a384cdbda↓ The reported Windows workload and warm-start impact remain unvalidated.
↓ The affected worker's job ownership and timing have not been established.
↓ No Windows reproduction or worker-ownership trace confirms this hypothesis.
Description
A reported Windows AppHost can encounter MSB4166 with MSBuild node reuse enabled. This draft mitigates a possible race where a new DCP run reuses a worker owned by the previous run's cleanup job. The root cause is not yet confirmed.
Assign each DCP run a fresh MSBuild handshake salt for coordinated builds and project rebuilders. Builds with the same original salt can still reuse workers within that run. Preserve existing build properties, run-property inputs, IDE metadata, runtime environments, and publishing behavior. No dependencies or public APIs are added.
Relates to #22560
User-facing usage
Existing
aspire runand Rebuild workflows automatically use the isolation; no opt-in is required. Cross-run worker reuse is lost, which can increase warm-start time. On Linux and macOS, previous workers can remain idle until MSBuild's timeout.Security considerations
MSBuild's undocumented handshake salt is not a security boundary: its handshake value is 32-bit and collisions are possible. A configured salt may contain sensitive data, so its composed value is registered with the existing backchannel redaction history before the DCP object is created. No formal threat model or security review has been completed.
Validation
All commands ran on macOS with
MSBUILDTERMINALLOGGER=false; the coordinator integration run also used a local NuGet mirror andNuGetAudit=false.dotnet test --project tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj --no-restore --no-launch-profile -- --filter-class '*.ExecutableLaunchPlanTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'dotnet test --project tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj --no-restore --no-launch-profile -- --filter-method '*.ManagedBuildEnvironmentIsIsolatedOnCreationAndRestart' --filter-method '*.EnsureDcpHostRunning_TransfersSessionFolderOwnershipToDcpOnlyWhenDcpStarts' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'dotnet test --project tests/Aspire.Hosting.Dotnet.Tests/Aspire.Hosting.Dotnet.Tests.csproj --no-restore --no-launch-profile -- --filter-method '*.MultipleBuildGroupsRunSeriallyBeforeServicesStart' --filter-method '*.HandshakeSaltIsolationDoesNotChangeBuildPropertiesOrProjectMetadata' --filter-method '*.PublishModeDoesNotCreateCoordinatedBuildOrSuppressProjectBuild' --filter-method '*.ContextSpecificBuildEnvironmentIsSharedWithinEachBuildAttempt' --filter-method '*.ProjectWithBuildEnvironmentUsesSerializedDirectBuild' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' --hangdump --hangdump-timeout 4mdotnet test --project tests/Aspire.Hosting.Blazor.Tests/Aspire.Hosting.Blazor.Tests.csproj --no-restore --no-launch-profile -- --filter-method '*.AddBlazorGateway_RendersCompleteProcessLaunchPlan' --filter-method '*.AddDotnetProjectBlazorGateway_RendersCompleteProcessLaunchPlan' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'Checklist
<remarks />and<code />elements on your triple slash comments?