Repository navigation
Fix multi-platform project container builds (RuntimeIdentifiers passed as one RID) - #21514
David Fowler (davidfowl) wants to merge 1 commit into
Conversation
Percent-escaping ';' in the RuntimeIdentifiers/ContainerRuntimeIdentifiers switches made MSBuild treat 'linux-x64;linux-arm64' as a single RID, so multi-platform project container builds failed with NETSDK1083. Escape each RID and quote the list so ';' stays a real item separator. Fixes #9281 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21514Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21514" |
Tests selector52 / 100 PR test projects · 4 PR jobs, from 3 changed files. Selected PR test projects (52 / 100)
Selected PR jobs (4)
How these were chosen — grouped by what changed
🔧 show 37
🔧 📦 affected project 🧪 📦 affected project Job reasons
Selection computed for commit |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the change addressing multi-platform runtime identifier handling.
No open issues 🎉
What changed in this PR
Fixes a regression in Aspire’s multi-platform .NET container publishing where MSBuild treated multiple runtime identifiers as one value, causing NETSDK1083.
Changes:
- Adds a list-property argument helper that escapes individual entries while preserving quoted semicolon separators.
- Uses the helper for multi-platform runtime properties, leaving single-platform arguments unchanged.
- Strengthens regression tests to verify that MSBuild expands both runtime properties into separate items.
| File | Description |
|---|---|
tests/Aspire.Hosting.Tests/Publishing/ResourceContainerImageManagerTests.cs |
Verifies quoted arguments and separate runtime items for project and file-based builds. |
src/Shared/MsBuildResponseFile.cs |
Adds argument formatting for list-valued MSBuild properties. |
src/Aspire.Hosting/Publishing/ResourceContainerImageManager.cs |
Applies list formatting to multi-platform runtime properties. |
Review effort: Balanced
|
CI note for exact head
🤖 Posted by AspireAgent (AI Agent) |
Description
Multi-platform container builds of .NET projects fail again in 13.6. With
WithContainerBuildOptions(ctx => ctx.TargetPlatform = ContainerTargetPlatform.AllLinux), the build fails like this (report on #9281):Root cause
#19997 moved
AddTargetPlatformArgumentstoMsBuildResponseFileFactory.CreatePropertyArgument, which percent-escapes;as%3B. That protects the switch from MSBuild's command-line splitting. However, an escaped;also stays literal when MSBuild expands the property into items. So the SDK seesRuntimeIdentifiersas one RID,linux-x64;linux-arm64, and its per-RID inner builds fail with NETSDK1083. Before #19997 the list was passed quoted (/p:RuntimeIdentifiers=\"linux-x64;linux-arm64\"), which is why 13.5.x worked.Fix
MsBuildResponseFileFactory.CreateListPropertyArgument. It percent-escapes each entry and joins the entries with real;inside quotes (--property:RuntimeIdentifiers="linux-x64;linux-arm64"). MSBuild's switch parser therefore keeps the value as one property, and item expansion still yields one RID per entry.RuntimeIdentifiersandContainerRuntimeIdentifierswhen more than one platform is targeted. Single-RID and all other properties are unchanged.Reproduction and before/after evidence
Minimal MSBuild semantics. I used a project with
<R Include="$(RuntimeIdentifiers)" />:@(R)--property:RuntimeIdentifiers=linux-x64%3Blinux-arm64(main)linux-x64;linux-arm64--property:RuntimeIdentifiers="linux-x64;linux-arm64"(this PR)linux-x64,linux-arm64Regression test. I strengthened
ResourceContainerImageBuilderTests.BuildImageAsync_MultiPlatformArgumentsSurviveMsBuildParsing(both the project and file-based variants). It already round-tripped the emitted switches through a realdotnet msbuild, but it only checked-getProperty, which prints the unescaped string, so it could not see the bug. It now also expands both properties into items and asserts["linux-x64", "linux-arm64"].%3Barguments main emits, both variants fail:BuildImageAsync_DynamicPropertiesSurviveMsBuildParsing.E2E evidence (real SDK container publish)
I ran a real
dotnet publish /t:PublishContaineron a freshdotnet new webproject with SDK 11.0.100-rc.2, archive destination, and the exact property switches Aspire emits:%3B):error NETSDK1083: The specified RuntimeIdentifier 'linux-x64;linux-arm64' is not recognized.This is the same error as in the issue report.Validation
ResourceContainerImageBuilderTests: 67 passed, 0 failed locally. I excluded the 11 tests that build real images, because this machine has too little disk for base-image layers and can't reach NuGet audit (NU1900). CI runs them.src/Aspire.Hosting.Dotnet, which also compiles the sharedMsBuildResponseFile.cs, builds cleanly.Fixes #9281
Checklist
<remarks />and<code />elements on your triple slash comments?🤖 Posted by AspireAgent (AI Agent)