Repository navigation
Fix multi-platform project container builds (RuntimeIdentifiers passed as one RID) - #21514
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" |
This comment has been minimized.
This comment has been minimized.
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) |
|
AspireAgent stopped: Ankit Jain (@radical)'s file-based app feedback is addressed and Final Results is green on 232eb0f. 🤖 Posted by AspireAgent (AI Agent) |
`dotnet publish app.cs` parses property switches in the .NET CLI and keeps quote characters, so the quoted RuntimeIdentifiers list failed with NETSDK1083 for '"linux-x64'. File-based apps now get the unquoted list; project-based builds keep the quoted form MSBuild needs. Adds a real file-based multi-platform archive publish test and probes the file-based argument round trip through `dotnet build app.cs`. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
#21009 added an expectation for the percent-escaped RuntimeIdentifiers list; project builds now pass the quoted list. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
I merged 🤖 Posted by AspireAgent (AI Agent) |
Ankit Jain (radical)
left a comment
There was a problem hiding this comment.
[automated] Two related, pre-existing multi-platform publishing issues remain. I reproduced both and validated the suggested fixes locally against the pre-merge head 655dcf3; neither fix is in the current PR head.
This comment has been minimized.
This comment has been minimized.
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
AspireAgent is addressing Ankit Jain (@radical)'s response-file and singular-RID review threads. 🤖 Posted by AspireAgent (AI Agent) |
…latform builds - Write build-environment response-file switches unquoted with a trailing ';' for file-based apps; the .NET CLI rejected whole-switch quotes and fell back to MSBuild (MSB1006 for linux-arm64 on AllLinux). - Clear RuntimeIdentifier and ContainerRuntimeIdentifier for multi-platform targets so inherited or project-defined singular RIDs cannot collapse the build to one image. - Extend the real file-based AllLinux publish test with build-environment and project-RID cases, and read only OCI index entries from the archive. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Tests selector52 / 101 PR test projects · 4 PR jobs, from 5 changed files. Selected PR test projects (52 / 101)
Selected PR jobs (4)
How these were chosen — grouped by what changed
🔧 show 32
🔧 show 15
📦 affected project 🧪 🧪 Job reasons
Selection computed for commit |
There was a problem hiding this comment.
🟡 Changes recommended
The new file-based response-file format lacks a round-trip test verifying that property values, including escaped semicolons and trailing Unicode whitespace, survive parsing unchanged.
1 open issue
1 resolved since last review
Review effort: Balanced
|
AspireAgent stopped after verifying merge readiness and submitting the squash merge (operation 2c257db7-ca61-4b70-a8ad-c451a36a1cdc). 🤖 Posted by AspireAgent (AI Agent) |
|
✅ No documentation update needed. Skipped. Branch: docs_optional → bug_fix_restores_documented_behavior (proven false positive).
|

Description
What failed
Multi-platform container builds of .NET programs fail in 13.6. With
WithContainerBuildOptions(ctx => ctx.TargetPlatform = ContainerTargetPlatform.AllLinux), project builds fail like this (report on #9281):File-based apps (
dotnet publish app.cs) fail the same way, and quoting the list alone makes them fail differently:Two related multi-platform problems surfaced in review:
WithDotnetProgramBuildEnvironment) fails withMSBUILD : error MSB1006: Property is not valid. Switch: linux-arm64.RuntimeIdentifier/ContainerRuntimeIdentifierpublishes successfully but produces a single-platform image.Why
#19997 moved
AddTargetPlatformArgumentstoMsBuildResponseFileFactory.CreatePropertyArgument, which percent-escapes;as%3B. That stops MSBuild's command-line parser from splitting the switch. But an escaped;also stays literal when MSBuild expands the property into items, so the SDK sees one RID,linux-x64;linux-arm64. Before #19997 the list was passed quoted, which is why 13.5.x worked.Project files and file-based apps parse the switch differently:
dotnet msbuild/dotnet publish app.csproj): MSBuild's switch parser splits an unquoted value on;, so the list has to be quoted.dotnet build|publish app.cs): the .NET CLI parses the switch itself and passes it to the virtual project as a global property. It keeps quote characters literally, and it appends;segments without=to the previous value. So the list has to be unquoted.Two further causes:
app.csas an MSBuild argument and handed everything to MSBuild, which then split the unquoted RID list.RuntimeIdentifierandContainerRuntimeIdentifierover the plural lists, and can derive the container RID fromRuntimeIdentifier. Any inherited or project-defined singular value therefore wins over the lists.Fix
MsBuildResponseFileFactory.CreateListPropertyArgumentpercent-escapes each entry and joins them with real;inside quotes (--property:RuntimeIdentifiers="linux-x64;linux-arm64"). This is used for project files.MsBuildResponseFileFactory.CreateFileBasedAppListPropertyArgumentemits the same list without quotes (--property:RuntimeIdentifiers=linux-x64;linux-arm64). This is used for file-based apps.AddTargetPlatformArgumentschooses between them usingIProjectMetadata.IsFileBasedApp. It applies toRuntimeIdentifiersandContainerRuntimeIdentifiersfor both thepublishcommand and theContainerWorkingDirectoryquery. Single-RID and all other properties are unchanged.AddTargetPlatformArgumentsalso emits--property:RuntimeIdentifier=and--property:ContainerRuntimeIdentifier=before the lists, so singular defaults cannot collapse the build into one image.MsBuildResponseFileFactory.CreateAsynctakesisFileBasedApp. File-based apps get one unquoted--property:Name=value;per line. The trailing;is consumed by the CLI parser and stops it from trimming trailing Unicode whitespace; values are still percent-escaped. Projects keep whole-switch quotes, and the project-onlyAspire.Hosting.Dotnetcaller passesfalse.Confidence
High for both paths. Each form was checked through a real SDK container publish for linux-x64 + linux-arm64, and each path now has a test that runs the CLI parser actually used for it. The 14 tests that load real images into Docker didn't run locally (see Validation); CI runs them.
How we stop this recurring
BuildImageAsync_MultiPlatformArgumentsSurviveMsBuildParsinground-trips the emitted switches through the real parser for each path:dotnet msbuild properties.projfor projects anddotnet build app.cs(viaDirectory.Build.props) for file-based apps. It asserts both the property string and the item expansion (["linux-x64", "linux-arm64"]). The probe also defines both singular RIDs and asserts that they evaluate empty. Before, the file-based variant probed a synthetic.proj, so it couldn't see the file-based app behaviour.CanBuildMultiPlatformArchiveFromFileBasedCSharpAppruns a realAllLinuxOCI archive publish of anapp.csthroughIResourceContainerImageManager. It asserts that the archive's image index containslinux/amd64andlinux/arm64. It has three cases: plain, with a build environment (response-file path), and withRuntimeIdentifier/ContainerRuntimeIdentifierset in the app. The archive reader only readsindex.jsonand the index blobs, not the layers.Before/after evidence
File-based app, real SDK publish (
dotnet publish app.cs /t:PublishContainer, archive output, SDK 11.0.100-rc.2):RuntimeIdentifiersswitch value"linux-x64;linux-arm64"(previous commit)NETSDK1083 ... '"linux-x64'/'linux-arm64"'linux-x64%3Blinux-arm64(main)NETSDK1083 ... 'linux-x64;linux-arm64'linux-x64;linux-arm64(this PR)Project, real SDK publish (
dotnet new web, same switches):%3Bfails with NETSDK1083 ('linux-x64;linux-arm64'). The quoted list buildslinux-x64andlinux-arm64images and an image index.Response file, real SDK publish (
dotnet publish app.cs, AllLinux OCI archive,@file.rsp):"--property:Foo=bar"fails withMSB1006 ... Switch: linux-arm64;--property:Foo=bar;writes the archive.Singular RID, real SDK publish (
app.cswith#:property RuntimeIdentifier=linux-x64, AllLinux OCI archive): without the empty singular properties, the archive has one image with no platform. With them, it haslinux/amd64andlinux/arm64.Regression tests, before (fix reverted in
src/) and after:CanBuildMultiPlatformArchiveFromFileBasedCSharpApp: before, it fails withNETSDK1083: The specified RuntimeIdentifier '"linux-x64' is not recognized. After, it passes.BuildImageAsync_MultiPlatformArgumentsSurviveMsBuildParsing(fileBased: True): before, it fails on the emitted arguments. After, it passes.CanBuildMultiPlatformArchiveFromFileBasedCSharpApp(withBuildEnvironment: True): before, it fails withMSB1006 ... Switch: linux-arm64. After, it passes.CanBuildMultiPlatformArchiveFromFileBasedCSharpApp(withProjectRuntimeIdentifiers: True): before,Expected "linux/amd64",Actual "/"(single image). After, it passes.BuildImageAsync_MultiPlatformArgumentsSurviveMsBuildParsing(both variants): before, they fail on the missing empty singular RIDs. After, they pass.CanBuildArchiveFromFileBasedCSharpApppasses in both runs.Validation
ResourceContainerImageBuilderTests,DotnetProgramPublishingTestsandDockerContainerRuntimeTests: 118 passed, 0 failed locally. This includes both real file-based archive publishes. I excluded 14 tests that load real images into Docker, because this machine runs out of disk for base-image layers. CI runs them.src/Aspire.Hosting.Dotnet, which also compiles the sharedMsBuildResponseFile.cs, builds cleanly. ItsDotnetProjectBuildEnvironmentTestspass. FiveDotnetProjectBuildCoordinatorTests(traversal restore and context-specific build) fail on this machine both with and without this change, so those failures are environmental.mainwas merged in so I could updateWslcDotnetPublishingTests.DotnetPublishing_ArchiveDoesNotInvokeWslc(from Add initial WSLc publish/deploy support with explicit capability limits #21009) to expect the quoted RID list for projects; the multi-platform expectation now also includes the empty singular RIDs. That class is Windows-only (SkipOnPlatformon Linux and macOS), so the Windows CI job verifies it.Fixes #9281
Checklist
<remarks />and<code />elements on your triple slash comments?🤖 Posted by AspireAgent (AI Agent)