You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add initial WSLc publish/deploy support with explicit capability limits - #21009
WSLc can run Aspire apps on Windows, but publishing currently has no WSLc runtime implementation. This adds an initial, deliberately limited publishing implementation so supported image operations use the selected runtime and unsupported operations fail clearly instead of falling back or working around WSLc limitations.
This PR targets main and builds on the runtime detection and doctor support from #21004, now incorporated into main.
Supported on Windows: local Dockerfile builds without platform selection, image tagging/removal/push, registry login, native JSON image configuration inspection, and single-platform .NET SDK publishing to WSLc's local image store. Auto-discovery retains Docker → Podman → WSLc priority; explicit case-insensitive selection and custom keyed runtimes remain supported.
Native SDK local publishing uses LocalRegistry=Wslc and requires an SDK containing the WSLc support introduced in dotnet/sdk#55249. It was verified with the repository-pinned SDK 11.0.100-rc.1.26425.128; older SDKs without this support report an unsupported registry rather than falling back to another runtime. Aspire does not implement an archive/load bridge.
Unsupported: Compose deployment/management, platform-selected Dockerfile builds, Dockerfile archives/OCI format selection, manifest inspection, multi-platform SDK publishing to WSLc's local image store, and container-file layering (which requires a platform-selected Dockerfile build). Multi-platform image loading is tracked by microsoft/WSL#41123. These paths reject explicitly using existing exception/inspection-result contracts. Daemon-free single- and multi-platform SDK archives remain supported without WSLc health checks or commands; archive publishing omits LocalRegistry=Wslc, preserving compatibility with SDKs that do not recognize it. No alternative builder or runtime fallback is introduced.
Dockerfile builds in Docker, Podman, and WSLc now use ProcessSpec.ArgumentList instead of a manually quoted command line. Shared eager argument helpers preserve quotes, spaces, backslashes, empty values, and inherited environment values, retaining Podman's existing secret behavior. Platform-specific process argument handling remains owned by .NET, without invoking a shell.
User-facing usage
On Windows, select WSLc with ASPIRE_CONTAINER_RUNTIME=wslc. Single-platform .NET SDK publishing then uses WSLc's local store through the SDK's native support.
Dockerfile publishing defaults to linux/amd64; explicitly opt into the WSLc host platform only when appropriate:
.\restore.cmd /p:SkipNativeBuild=true — passed during initial setup.
.\.dotnet\dotnet.exe test --project tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj --no-launch-profile /p:SkipNativeBuild=true -- --filter-class '*.WslcContainerRuntimeTests' --filter-class '*.ContainerRuntimeResolverTests' --filter-class '*.ContainerRuntimeDetectorTests' --filter-class '*.DockerContainerRuntimeTests' --filter-class '*.ContainerRuntimeBaseTests' --filter-class '*.DotnetProgramArchiveTests' --filter-class '*.DotnetProgramPublishingTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' — passed, 151 tests after merging main, before the argument-list correction.
.\.dotnet\dotnet.exe test --project tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj --no-launch-profile /p:SkipNativeBuild=true -- --filter-class '*.ContainerRuntimeBaseTests' --filter-class '*.DockerContainerRuntimeTests' --filter-class '*.PodmanSaveArgumentsTests' --filter-class '*.WslcContainerRuntimeTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' — passed, 95 tests after the argument-list correction and eager helper changes. The runtime-constant follow-up was rebuilt with --filter-method '*.BuildImageAsync_PreservesArgumentBoundaries' (same project and exclusions) — passed, 3 cases. The complete 95-test selection was rerun with --no-build immediately before pushing — passed.
.\.dotnet\dotnet.exe test --project tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj --no-build --no-launch-profile -- --filter-method '*.BuildSecretsFormats*' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' — passed, 4 tests after the argument-list correction.
.\.dotnet\dotnet.exe test --project tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj --no-build --no-launch-profile -- --filter-class '*.DotnetProgramArchiveTests' --filter-class '*.DotnetProgramPublishingTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' — passed, 48 tests after the argument-list correction.
.\.dotnet\dotnet.exe test --project tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj --no-build --no-launch-profile -- --filter-method '*.BuildImageAsync_Dotnet*' --filter-method '*.BuildImageAsync_ProjectBuildPassesResolvedContainerRuntimeAsLocalRegistry' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' — passed, 20 tests after the SDK correction and before the main merge.
.\.dotnet\dotnet.exe publish '<probe-directory>\probe.csproj' --configuration Release /t:PublishContainer --property:LocalRegistry=Wslc --property:ContainerRepository=aspire-wslc-sdk-probe-b35fa7a4 --property:ContainerImageTag=single --property:RuntimeIdentifier=linux-x64 --property:ContainerRuntimeIdentifier=linux-x64 --property:ContainerBaseImage=mcr.microsoft.com/dotnet/runtime:10.0 --source https://packagefeedproxy.microsoft.io/nuget/v3/index.json — passed using a temporary minimal net10.0 console project and SDK 11.0.100-rc.1.26425.128. SDK reported successful publication via Wslc; wslc image inspect aspire-wslc-sdk-probe-b35fa7a4:single --format json confirmed linux/amd64. Probe image and project cleaned up; the path above is a placeholder for that temporary directory.
Installed WSLc 3.0.3.0: verified local Dockerfile build and native image inspect --format json; inspected tag/remove/push/login/build help and DCP's WSLc adapter. Direct --output type=docker and --output type=oci probes both failed with the Docker-driver exporter limitation, confirming the explicit archive boundary. Probe image/files cleaned up.
Local E2E tests were not run; no E2E tests were added. Linux/macOS execution and live registry push/login were not validated locally.
Existing NU1902/NU1903 warnings for System.Security.Cryptography.Pkcs 10.0.12 remain; no dependency changes are included.
Security considerations
The selected WSLc executable is trusted in the same way as Docker/Podman. Image commands use the existing process runner; registry passwords remain on stdin and environment build secrets follow the existing runtime pattern. Native image inspection uses source-generated JSON deserialization and preserves the image reference as a single process argument. Dockerfile build invocations for all three runtimes now preserve argument boundaries through ProcessSpec.ArgumentList. No listener, elevated execution, archive extraction, or Aspire-managed archive/load bridge is added. A separate security review has not been performed.
Fixes # (issue)
Checklist
Is this feature complete?
Yes. Ready to ship.
No. Follow-up changes expected.
Are you including unit tests for the changes and scenario tests if relevant?
Yes
No
Did you add public API?
Yes
If yes, did you have an API Review for it?
Yes
No
Did you add <remarks /> and <code /> elements on your triple slash comments?
Yes
No
No
Does the change make any security assumptions or guarantees?
Yes
If yes, have you done a threat model and had a security review?
On Windows with no runtime configured, SDK archive publishing still runs WSLc probes. BuildImagesAsync resolves the runtime before checking whether it is needed, and both BuildDotnetProgramImageAsync and ExecuteDotnetPublishAsync resolve it unconditionally. Removing this filter adds wslc container ls -n 1 and potentially wslc info to those archive builds, contrary to the promised no-WSLc-command behavior, and makes them wait for probe completion or timeouts. Skip runtime resolution for SDK archives without container-file layering. Add coverage with automatic selection; the new archive tests explicitly configure WSLc and bypass discovery.
Preserve drive-root separators during context normalization
The copied normalization strips the separator from a drive-root context such as C:\, producing the drive-relative path C:. WSLc can then build from that drive's current directory instead of the requested root. Preserve the full path; ArgumentList already handles trailing backslashes safely. Please also cover a drive-root context in the argument tests.
ArgumentList preserves process argument boundaries, but WSLc parses each --secret value as a CSV record. The shared helper formats C:\work\team,a\.npmrc as id=npmrc,type=file,src=C:\work\team,a\.npmrc; WSLc then rejects a\.npmrc because it is not a key=value field. Encode the individual CSV fields for WSLc, independently of process argument quoting, and add a regression test with a comma in the parent directory. Preserve Podman's existing secret syntax if changing the shared helper.
Updated WSLc docs from "no publish/deploy" to initial limited publish support. Signals: pr_body_has_user_facing_section (PR body "User-facing usage" on ASPIRE_CONTAINER_RUNTIME=wslc), pr_body_has_cli_flag_mention. Files: app-host/configuration.mdx, get-started/prerequisites.mdx.
David Negstad (@danegsta) backporting to release/17.0 failed, the patch most likely resulted in conflicts. Please backport manually!
git am output
$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patchApplying: Support WSLc in Aspire doctor runtime checksUsing index info to reconstruct a base tree...M docs/machine-requirements.mdM src/Aspire.Cli/Aspire.Cli.csprojM src/Aspire.Cli/Utils/EnvironmentChecker/ContainerRuntimeCheck.csM src/Aspire.Hosting/Aspire.Hosting.csprojM src/Aspire.Hosting/Publishing/ContainerRuntimeResolver.csM src/Shared/ContainerRuntimeDetector.csM src/Shared/KnownContainerRuntimes.csM tests/Aspire.Cli.Tests/Utils/ContainerRuntimeCheckTests.csM tests/Aspire.Hosting.TestUtilities/Utils/DockerUtils.csM tests/Aspire.Hosting.Tests/Publishing/ContainerRuntimeDetectorTests.csFalling back to patching base and 3-way merge...Auto-merging docs/machine-requirements.mdCONFLICT (content): Merge conflict in docs/machine-requirements.mdAuto-merging src/Aspire.Cli/Aspire.Cli.csprojAuto-merging src/Aspire.Cli/Utils/EnvironmentChecker/ContainerRuntimeCheck.csCONFLICT (content): Merge conflict in src/Aspire.Cli/Utils/EnvironmentChecker/ContainerRuntimeCheck.csAuto-merging src/Aspire.Hosting/Aspire.Hosting.csprojAuto-merging src/Aspire.Hosting/Publishing/ContainerRuntimeResolver.csCONFLICT (content): Merge conflict in src/Aspire.Hosting/Publishing/ContainerRuntimeResolver.csAuto-merging src/Shared/ContainerRuntimeDetector.csCONFLICT (content): Merge conflict in src/Shared/ContainerRuntimeDetector.csAuto-merging src/Shared/ContainerRuntimeProbe.csCONFLICT (add/add): Merge conflict in src/Shared/ContainerRuntimeProbe.csAuto-merging src/Shared/WslcContainerRuntimeProbe.csCONFLICT (add/add): Merge conflict in src/Shared/WslcContainerRuntimeProbe.csAuto-merging tests/Aspire.Cli.Tests/Utils/ContainerRuntimeCheckTests.csAuto-merging tests/Aspire.Hosting.Tests/Publishing/ContainerRuntimeDetectorTests.csCONFLICT (content): Merge conflict in tests/Aspire.Hosting.Tests/Publishing/ContainerRuntimeDetectorTests.cserror: Failed to merge in the changes.hint: Use 'git am --show-current-patch=diff' to see the failed patchhint: When you have resolved this problem, run "git am --continue".hint: If you prefer to skip this patch, run "git am --skip" instead.hint: To restore the original branch and stop patching, run "git am --abort".hint: Disable this message with "git config set advice.mergeConflict false"Patch failed at 0001 Support WSLc in Aspire doctor runtime checksError: The process '/usr/bin/git' failed with exit code 128
…ts (#21009)
## Description
WSLc can run Aspire apps on Windows, but publishing currently has no
WSLc runtime implementation. This adds an initial, deliberately limited
publishing implementation so supported image operations use the selected
runtime and unsupported operations fail clearly instead of falling back
or working around WSLc limitations.
This PR targets `main` and builds on the runtime detection and doctor
support from #21004, now incorporated into `main`.
Supported on Windows: local Dockerfile builds without platform
selection, image tagging/removal/push, registry login, native JSON image
configuration inspection, and single-platform .NET SDK publishing to
WSLc's local image store. Auto-discovery retains Docker → Podman → WSLc
priority; explicit case-insensitive selection and custom keyed runtimes
remain supported.
Native SDK local publishing uses `LocalRegistry=Wslc` and requires an
SDK containing the WSLc support introduced in
[dotnet/sdk#55249](dotnet/sdk#55249). It was
verified with the repository-pinned SDK `11.0.100-rc.1.26425.128`; older
SDKs without this support report an unsupported registry rather than
falling back to another runtime. Aspire does not implement an
archive/load bridge.
Unsupported: Compose deployment/management, platform-selected Dockerfile
builds, Dockerfile archives/OCI format selection, manifest inspection,
multi-platform SDK publishing to WSLc's local image store, and
container-file layering (which requires a platform-selected Dockerfile
build). Multi-platform image loading is tracked by
[microsoft/WSL#41123](microsoft/WSL#41123).
These paths reject explicitly using existing exception/inspection-result
contracts. Daemon-free single- and multi-platform SDK archives remain
supported without WSLc health checks or commands; archive publishing
omits `LocalRegistry=Wslc`, preserving compatibility with SDKs that do
not recognize it. No alternative builder or runtime fallback is
introduced.
Dockerfile builds in Docker, Podman, and WSLc now use
`ProcessSpec.ArgumentList` instead of a manually quoted command line.
Shared eager argument helpers preserve quotes, spaces, backslashes,
empty values, and inherited environment values, retaining Podman's
existing secret behavior. Platform-specific process argument handling
remains owned by .NET, without invoking a shell.
### User-facing usage
On Windows, select WSLc with `ASPIRE_CONTAINER_RUNTIME=wslc`.
Single-platform .NET SDK publishing then uses WSLc's local store through
the SDK's native support.
Dockerfile publishing defaults to `linux/amd64`; explicitly opt into the
WSLc host platform only when appropriate:
```csharp
builder.AddDockerfile("program", "./program")
.WithContainerBuildOptions(options => options.TargetPlatform = null);
```
For a .NET SDK archive without container-file layering:
```csharp
project.WithContainerBuildOptions(options =>
{
options.Destination = ContainerImageDestination.Archive;
options.OutputPath = "./images";
});
```
### Validation
- `.\restore.cmd /p:SkipNativeBuild=true` — passed during initial setup.
- `.\.dotnet\dotnet.exe test --project
tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj
--no-launch-profile /p:SkipNativeBuild=true -- --filter-class
'*.WslcContainerRuntimeTests' --filter-class
'*.ContainerRuntimeResolverTests' --filter-class
'*.ContainerRuntimeDetectorTests' --filter-class
'*.DockerContainerRuntimeTests' --filter-class
'*.ContainerRuntimeBaseTests' --filter-class
'*.DotnetProgramArchiveTests' --filter-class
'*.DotnetProgramPublishingTests' --filter-not-trait 'quarantined=true'
--filter-not-trait 'outerloop=true'` — passed, 151 tests after merging
`main`, before the argument-list correction.
- `.\.dotnet\dotnet.exe test --project
tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj
--no-launch-profile /p:SkipNativeBuild=true -- --filter-class
'*.ContainerRuntimeBaseTests' --filter-class
'*.DockerContainerRuntimeTests' --filter-class
'*.PodmanSaveArgumentsTests' --filter-class
'*.WslcContainerRuntimeTests' --filter-not-trait 'quarantined=true'
--filter-not-trait 'outerloop=true'` — passed, 95 tests after the
argument-list correction and eager helper changes. The runtime-constant
follow-up was rebuilt with `--filter-method
'*.BuildImageAsync_PreservesArgumentBoundaries'` (same project and
exclusions) — passed, 3 cases. The complete 95-test selection was rerun
with `--no-build` immediately before pushing — passed.
- `.\.dotnet\dotnet.exe test --project
tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj --no-build
--no-launch-profile -- --filter-method '*.BuildSecretsFormats*'
--filter-not-trait 'quarantined=true' --filter-not-trait
'outerloop=true'` — passed, 4 tests after the argument-list correction.
- `.\.dotnet\dotnet.exe test --project
tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj --no-build
--no-launch-profile -- --filter-class '*.DotnetProgramArchiveTests'
--filter-class '*.DotnetProgramPublishingTests' --filter-not-trait
'quarantined=true' --filter-not-trait 'outerloop=true'` — passed, 48
tests after the argument-list correction.
- `.\.dotnet\dotnet.exe test --project
tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj --no-build
--no-launch-profile -- --filter-method '*.BuildImageAsync_Dotnet*'
--filter-method
'*.BuildImageAsync_ProjectBuildPassesResolvedContainerRuntimeAsLocalRegistry'
--filter-not-trait 'quarantined=true' --filter-not-trait
'outerloop=true'` — passed, 20 tests after the SDK correction and before
the `main` merge.
- `.\.dotnet\dotnet.exe publish '<probe-directory>\probe.csproj'
--configuration Release /t:PublishContainer
--property:LocalRegistry=Wslc
--property:ContainerRepository=aspire-wslc-sdk-probe-b35fa7a4
--property:ContainerImageTag=single
--property:RuntimeIdentifier=linux-x64
--property:ContainerRuntimeIdentifier=linux-x64
--property:ContainerBaseImage=mcr.microsoft.com/dotnet/runtime:10.0
--source https://packagefeedproxy.microsoft.io/nuget/v3/index.json` —
passed using a temporary minimal net10.0 console project and SDK
`11.0.100-rc.1.26425.128`. SDK reported successful publication via Wslc;
`wslc image inspect aspire-wslc-sdk-probe-b35fa7a4:single --format json`
confirmed linux/amd64. Probe image and project cleaned up; the path
above is a placeholder for that temporary directory.
- Installed WSLc 3.0.3.0: verified local Dockerfile build and native
`image inspect --format json`; inspected tag/remove/push/login/build
help and DCP's WSLc adapter. Direct `--output type=docker` and `--output
type=oci` probes both failed with the Docker-driver exporter limitation,
confirming the explicit archive boundary. Probe image/files cleaned up.
- Local E2E tests were not run; no E2E tests were added. Linux/macOS
execution and live registry push/login were not validated locally.
- Existing NU1902/NU1903 warnings for
`System.Security.Cryptography.Pkcs` 10.0.12 remain; no dependency
changes are included.
### Security considerations
The selected WSLc executable is trusted in the same way as
Docker/Podman. Image commands use the existing process runner; registry
passwords remain on stdin and environment build secrets follow the
existing runtime pattern. Native image inspection uses source-generated
JSON deserialization and preserves the image reference as a single
process argument. Dockerfile build invocations for all three runtimes
now preserve argument boundaries through `ProcessSpec.ArgumentList`. No
listener, elevated execution, archive extraction, or Aspire-managed
archive/load bridge is added. A separate security review has not been
performed.
Fixes # (issue)
## Checklist
- Is this feature complete?
- [x] Yes. Ready to ship.
- [ ] No. Follow-up changes expected.
- Are you including unit tests for the changes and scenario tests if
relevant?
- [x] Yes
- [ ] No
- Did you add public API?
- [ ] Yes
- If yes, did you have an API Review for it?
- [ ] Yes
- [ ] No
- Did you add `<remarks />` and `<code />` elements on your triple slash
comments?
- [ ] Yes
- [ ] No
- [x] No
- Does the change make any security assumptions or guarantees?
- [ ] Yes
- If yes, have you done a threat model and had a security review?
- [ ] Yes
- [x] No
- [x] No
---------
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: f85e4b06-371e-465a-8fd8-e635d14ec41f
Copilot-Session: b35fa7a4-1433-4b70-9840-5f5866230ff4
(cherry picked from commit 64ba1eb)
…ts (#21009)
## Description
WSLc can run Aspire apps on Windows, but publishing currently has no
WSLc runtime implementation. This adds an initial, deliberately limited
publishing implementation so supported image operations use the selected
runtime and unsupported operations fail clearly instead of falling back
or working around WSLc limitations.
This PR targets `main` and builds on the runtime detection and doctor
support from #21004, now incorporated into `main`.
Supported on Windows: local Dockerfile builds without platform
selection, image tagging/removal/push, registry login, native JSON image
configuration inspection, and single-platform .NET SDK publishing to
WSLc's local image store. Auto-discovery retains Docker → Podman → WSLc
priority; explicit case-insensitive selection and custom keyed runtimes
remain supported.
Native SDK local publishing uses `LocalRegistry=Wslc` and requires an
SDK containing the WSLc support introduced in
[dotnet/sdk#55249](dotnet/sdk#55249). It was
verified with the repository-pinned SDK `11.0.100-rc.1.26425.128`; older
SDKs without this support report an unsupported registry rather than
falling back to another runtime. Aspire does not implement an
archive/load bridge.
Unsupported: Compose deployment/management, platform-selected Dockerfile
builds, Dockerfile archives/OCI format selection, manifest inspection,
multi-platform SDK publishing to WSLc's local image store, and
container-file layering (which requires a platform-selected Dockerfile
build). Multi-platform image loading is tracked by
[microsoft/WSL#41123](microsoft/WSL#41123).
These paths reject explicitly using existing exception/inspection-result
contracts. Daemon-free single- and multi-platform SDK archives remain
supported without WSLc health checks or commands; archive publishing
omits `LocalRegistry=Wslc`, preserving compatibility with SDKs that do
not recognize it. No alternative builder or runtime fallback is
introduced.
Dockerfile builds in Docker, Podman, and WSLc now use
`ProcessSpec.ArgumentList` instead of a manually quoted command line.
Shared eager argument helpers preserve quotes, spaces, backslashes,
empty values, and inherited environment values, retaining Podman's
existing secret behavior. Platform-specific process argument handling
remains owned by .NET, without invoking a shell.
### User-facing usage
On Windows, select WSLc with `ASPIRE_CONTAINER_RUNTIME=wslc`.
Single-platform .NET SDK publishing then uses WSLc's local store through
the SDK's native support.
Dockerfile publishing defaults to `linux/amd64`; explicitly opt into the
WSLc host platform only when appropriate:
```csharp
builder.AddDockerfile("program", "./program")
.WithContainerBuildOptions(options => options.TargetPlatform = null);
```
For a .NET SDK archive without container-file layering:
```csharp
project.WithContainerBuildOptions(options =>
{
options.Destination = ContainerImageDestination.Archive;
options.OutputPath = "./images";
});
```
### Validation
- `.\restore.cmd /p:SkipNativeBuild=true` — passed during initial setup.
- `.\.dotnet\dotnet.exe test --project
tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj
--no-launch-profile /p:SkipNativeBuild=true -- --filter-class
'*.WslcContainerRuntimeTests' --filter-class
'*.ContainerRuntimeResolverTests' --filter-class
'*.ContainerRuntimeDetectorTests' --filter-class
'*.DockerContainerRuntimeTests' --filter-class
'*.ContainerRuntimeBaseTests' --filter-class
'*.DotnetProgramArchiveTests' --filter-class
'*.DotnetProgramPublishingTests' --filter-not-trait 'quarantined=true'
--filter-not-trait 'outerloop=true'` — passed, 151 tests after merging
`main`, before the argument-list correction.
- `.\.dotnet\dotnet.exe test --project
tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj
--no-launch-profile /p:SkipNativeBuild=true -- --filter-class
'*.ContainerRuntimeBaseTests' --filter-class
'*.DockerContainerRuntimeTests' --filter-class
'*.PodmanSaveArgumentsTests' --filter-class
'*.WslcContainerRuntimeTests' --filter-not-trait 'quarantined=true'
--filter-not-trait 'outerloop=true'` — passed, 95 tests after the
argument-list correction and eager helper changes. The runtime-constant
follow-up was rebuilt with `--filter-method
'*.BuildImageAsync_PreservesArgumentBoundaries'` (same project and
exclusions) — passed, 3 cases. The complete 95-test selection was rerun
with `--no-build` immediately before pushing — passed.
- `.\.dotnet\dotnet.exe test --project
tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj --no-build
--no-launch-profile -- --filter-method '*.BuildSecretsFormats*'
--filter-not-trait 'quarantined=true' --filter-not-trait
'outerloop=true'` — passed, 4 tests after the argument-list correction.
- `.\.dotnet\dotnet.exe test --project
tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj --no-build
--no-launch-profile -- --filter-class '*.DotnetProgramArchiveTests'
--filter-class '*.DotnetProgramPublishingTests' --filter-not-trait
'quarantined=true' --filter-not-trait 'outerloop=true'` — passed, 48
tests after the argument-list correction.
- `.\.dotnet\dotnet.exe test --project
tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj --no-build
--no-launch-profile -- --filter-method '*.BuildImageAsync_Dotnet*'
--filter-method
'*.BuildImageAsync_ProjectBuildPassesResolvedContainerRuntimeAsLocalRegistry'
--filter-not-trait 'quarantined=true' --filter-not-trait
'outerloop=true'` — passed, 20 tests after the SDK correction and before
the `main` merge.
- `.\.dotnet\dotnet.exe publish '<probe-directory>\probe.csproj'
--configuration Release /t:PublishContainer
--property:LocalRegistry=Wslc
--property:ContainerRepository=aspire-wslc-sdk-probe-b35fa7a4
--property:ContainerImageTag=single
--property:RuntimeIdentifier=linux-x64
--property:ContainerRuntimeIdentifier=linux-x64
--property:ContainerBaseImage=mcr.microsoft.com/dotnet/runtime:10.0
--source https://packagefeedproxy.microsoft.io/nuget/v3/index.json` —
passed using a temporary minimal net10.0 console project and SDK
`11.0.100-rc.1.26425.128`. SDK reported successful publication via Wslc;
`wslc image inspect aspire-wslc-sdk-probe-b35fa7a4:single --format json`
confirmed linux/amd64. Probe image and project cleaned up; the path
above is a placeholder for that temporary directory.
- Installed WSLc 3.0.3.0: verified local Dockerfile build and native
`image inspect --format json`; inspected tag/remove/push/login/build
help and DCP's WSLc adapter. Direct `--output type=docker` and `--output
type=oci` probes both failed with the Docker-driver exporter limitation,
confirming the explicit archive boundary. Probe image/files cleaned up.
- Local E2E tests were not run; no E2E tests were added. Linux/macOS
execution and live registry push/login were not validated locally.
- Existing NU1902/NU1903 warnings for
`System.Security.Cryptography.Pkcs` 10.0.12 remain; no dependency
changes are included.
### Security considerations
The selected WSLc executable is trusted in the same way as
Docker/Podman. Image commands use the existing process runner; registry
passwords remain on stdin and environment build secrets follow the
existing runtime pattern. Native image inspection uses source-generated
JSON deserialization and preserves the image reference as a single
process argument. Dockerfile build invocations for all three runtimes
now preserve argument boundaries through `ProcessSpec.ArgumentList`. No
listener, elevated execution, archive extraction, or Aspire-managed
archive/load bridge is added. A separate security review has not been
performed.
Fixes # (issue)
## Checklist
- Is this feature complete?
- [x] Yes. Ready to ship.
- [ ] No. Follow-up changes expected.
- Are you including unit tests for the changes and scenario tests if
relevant?
- [x] Yes
- [ ] No
- Did you add public API?
- [ ] Yes
- If yes, did you have an API Review for it?
- [ ] Yes
- [ ] No
- Did you add `<remarks />` and `<code />` elements on your triple slash
comments?
- [ ] Yes
- [ ] No
- [x] No
- Does the change make any security assumptions or guarantees?
- [ ] Yes
- If yes, have you done a threat model and had a security review?
- [ ] Yes
- [x] No
- [x] No
---------
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: f85e4b06-371e-465a-8fd8-e635d14ec41f
Copilot-Session: b35fa7a4-1433-4b70-9840-5f5866230ff4
(cherry picked from commit 64ba1eb)
…capability limits (#21991)
Backport of #21009 to release/17.0.
## Customer Impact
Users running containers through WSLc on Windows can't use Aspire 17.0
to build, publish, or deploy container images. WSLc is not recognized as
a container runtime for publish and deploy, so these operations fail or
select the wrong runtime. This change adds a WSLc container runtime, and
`aspire doctor` reports explicit capability limits for features that
WSLc doesn't support.
## Testing
- The original PR passed CI on main.
- Ran locally on macOS against this branch:
- `dotnet test --project
tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj
--no-launch-profile -- --filter-class "*.ContainerRuntimeBaseTests"
--filter-class "*.ContainerRuntimeResolverTests" --filter-class
"*.DockerContainerRuntimeTests" --filter-class
"*.PodmanSaveArgumentsTests" --filter-class
"*.ResourceContainerImageManagerTests" --filter-class
"*.WslcContainerRuntimeTests" --filter-class
"*.ContainerRuntimeDetectorTests" --filter-not-trait "quarantined=true"
--filter-not-trait "outerloop=true"`: **passed** (84/84)
- `dotnet test --project tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj
--no-launch-profile -- --filter-class "*.ContainerRuntimeCheckTests"
--filter-not-trait "quarantined=true" --filter-not-trait
"outerloop=true"`: **passed** (78/78)
- `WslcDotnetPublishingTests` is Windows-only and was skipped locally.
Windows CI on this PR covers it.
## Risk
Low to medium. The new behavior applies only when WSLc is the selected
container runtime. However, the change also touches shared container
runtime code (`ContainerRuntimeBase`, `ContainerRuntimeResolver`, the
Docker and Podman runtimes, `ResourceContainerImageManager`, and
`ContainerRuntimeDetector`), which affects all runtimes. The existing
Docker and Podman unit tests pass. Publishing with `LocalRegistry=Wslc`
also requires an SDK that includes dotnet/sdk#55249.
## Regression?
No. This is new functionality for WSLc users.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: f85e4b06-371e-465a-8fd8-e635d14ec41f
Copilot-Session: b35fa7a4-1433-4b70-9840-5f5866230ff4
#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>
…d as one RID) (#21514)
## 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](#9281 (comment))):
```
error NETSDK1083: The specified RuntimeIdentifier 'linux-x64;linux-arm64' is not recognized.
```
File-based apps (`dotnet publish app.cs`) fail the same way, and quoting
the list alone makes them fail differently:
```
error NETSDK1083: The specified RuntimeIdentifier '"linux-x64' is not recognized.
error NETSDK1083: The specified RuntimeIdentifier 'linux-arm64"' is not recognized.
```
Two related multi-platform problems surfaced in review:
- A file-based app with a build environment
(`WithDotnetProgramBuildEnvironment`) fails with `MSBUILD : error
MSB1006: Property is not valid. Switch: linux-arm64`.
- An app or project that defines or inherits `RuntimeIdentifier` /
`ContainerRuntimeIdentifier` publishes successfully but produces a
single-platform image.
### Why
#19997 moved `AddTargetPlatformArguments` to
`MsBuildResponseFileFactory.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:
- **Project files** (`dotnet msbuild` / `dotnet publish app.csproj`):
MSBuild's switch parser splits an unquoted value on `;`, so the list has
to be quoted.
- **File-based apps** (`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:
- **Response file:** the build-environment response file wrapped each
switch in quotes. The .NET CLI does not recognize a quoted switch for a
file-based app, so it treated `app.cs` as an MSBuild argument and handed
everything to MSBuild, which then split the unquoted RID list.
- **Singular RIDs:** the SDK prefers `RuntimeIdentifier` and
`ContainerRuntimeIdentifier` over the plural lists, and can derive the
container RID from `RuntimeIdentifier`. Any inherited or project-defined
singular value therefore wins over the lists.
### Fix
- `MsBuildResponseFileFactory.CreateListPropertyArgument`
percent-escapes each entry and joins them with real `;` inside quotes
(`--property:RuntimeIdentifiers="linux-x64;linux-arm64"`). This is used
for project files.
- `MsBuildResponseFileFactory.CreateFileBasedAppListPropertyArgument`
emits the same list without quotes
(`--property:RuntimeIdentifiers=linux-x64;linux-arm64`). This is used
for file-based apps.
- `AddTargetPlatformArguments` chooses between them using
`IProjectMetadata.IsFileBasedApp`. It applies to `RuntimeIdentifiers`
and `ContainerRuntimeIdentifiers` for both the `publish` command and the
`ContainerWorkingDirectory` query. Single-RID and all other properties
are unchanged.
- For multi-platform targets, `AddTargetPlatformArguments` also emits
`--property:RuntimeIdentifier=` and
`--property:ContainerRuntimeIdentifier=` before the lists, so singular
defaults cannot collapse the build into one image.
- `MsBuildResponseFileFactory.CreateAsync` takes `isFileBasedApp`.
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-only `Aspire.Hosting.Dotnet`
caller passes `false`.
### 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_MultiPlatformArgumentsSurviveMsBuildParsing`
round-trips the emitted switches through the real parser for each path:
`dotnet msbuild properties.proj` for projects and `dotnet build app.cs`
(via `Directory.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.
- New `CanBuildMultiPlatformArchiveFromFileBasedCSharpApp` runs a real
`AllLinux` OCI archive publish of an `app.cs` through
`IResourceContainerImageManager`. It asserts that the archive's image
index contains `linux/amd64` and `linux/arm64`. It has three cases:
plain, with a build environment (response-file path), and with
`RuntimeIdentifier` / `ContainerRuntimeIdentifier` set in the app. The
archive reader only reads `index.json` and 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):
| `RuntimeIdentifiers` switch value | Result |
|---|---|
| `"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) | Builds both RIDs, creates the
image index and writes the archive |
**Project, real SDK publish** (`dotnet new web`, same switches): `%3B`
fails with NETSDK1083 (`'linux-x64;linux-arm64'`). The quoted list
builds `linux-x64` and `linux-arm64` images and an image index.
**Response file, real SDK publish** (`dotnet publish app.cs`, AllLinux
OCI archive, `@file.rsp`): `"--property:Foo=bar"` fails with `MSB1006
... Switch: linux-arm64`; `--property:Foo=bar;` writes the archive.
**Singular RID, real SDK publish** (`app.cs` with `#:property
RuntimeIdentifier=linux-x64`, AllLinux OCI archive): without the empty
singular properties, the archive has one image with no platform. With
them, it has `linux/amd64` and `linux/arm64`.
**Regression tests**, before (fix reverted in `src/`) and after:
- `CanBuildMultiPlatformArchiveFromFileBasedCSharpApp`: before, it fails
with `NETSDK1083: 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 with `MSB1006 ... 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.
- `CanBuildArchiveFromFileBasedCSharpApp` passes in both runs.
### Validation
- `ResourceContainerImageBuilderTests`, `DotnetProgramPublishingTests`
and `DockerContainerRuntimeTests`: 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 shared
`MsBuildResponseFile.cs`, builds cleanly. Its
`DotnetProjectBuildEnvironmentTests` pass. Five
`DotnetProjectBuildCoordinatorTests` (traversal restore and
context-specific build) fail on this machine both with and without this
change, so those failures are environmental.
- `main` was merged in so I could update
`WslcDotnetPublishingTests.DotnetPublishing_ArchiveDoesNotInvokeWslc`
(from #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 (`SkipOnPlatform` on Linux and
macOS), so the Windows CI job verifies it.
Fixes#9281
## Checklist
- Is this feature complete?
- [x] Yes. Ready to ship.
- [ ] No. Follow-up changes expected.
- Are you including unit tests for the changes and scenario tests if
relevant?
- [x] Yes
- [ ] No
- Did you add public API?
- [ ] Yes
- If yes, did you have an API Review for it?
- [ ] Yes
- [ ] No
- Did you add `<remarks />` and `<code />` elements on your triple slash
comments?
- [ ] Yes
- [ ] No
- [x] No
- Does the change make any security assumptions or guarantees?
- [ ] Yes
- If yes, have you done a threat model and had a security review?
- [ ] Yes
- [ ] No
- [x] No
**🤖 Posted by AspireAgent (AI Agent)**
---------
Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
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
WSLc can run Aspire apps on Windows, but publishing currently has no WSLc runtime implementation. This adds an initial, deliberately limited publishing implementation so supported image operations use the selected runtime and unsupported operations fail clearly instead of falling back or working around WSLc limitations.
This PR targets
mainand builds on the runtime detection and doctor support from #21004, now incorporated intomain.Supported on Windows: local Dockerfile builds without platform selection, image tagging/removal/push, registry login, native JSON image configuration inspection, and single-platform .NET SDK publishing to WSLc's local image store. Auto-discovery retains Docker → Podman → WSLc priority; explicit case-insensitive selection and custom keyed runtimes remain supported.
Native SDK local publishing uses
LocalRegistry=Wslcand requires an SDK containing the WSLc support introduced in dotnet/sdk#55249. It was verified with the repository-pinned SDK11.0.100-rc.1.26425.128; older SDKs without this support report an unsupported registry rather than falling back to another runtime. Aspire does not implement an archive/load bridge.Unsupported: Compose deployment/management, platform-selected Dockerfile builds, Dockerfile archives/OCI format selection, manifest inspection, multi-platform SDK publishing to WSLc's local image store, and container-file layering (which requires a platform-selected Dockerfile build). Multi-platform image loading is tracked by microsoft/WSL#41123. These paths reject explicitly using existing exception/inspection-result contracts. Daemon-free single- and multi-platform SDK archives remain supported without WSLc health checks or commands; archive publishing omits
LocalRegistry=Wslc, preserving compatibility with SDKs that do not recognize it. No alternative builder or runtime fallback is introduced.Dockerfile builds in Docker, Podman, and WSLc now use
ProcessSpec.ArgumentListinstead of a manually quoted command line. Shared eager argument helpers preserve quotes, spaces, backslashes, empty values, and inherited environment values, retaining Podman's existing secret behavior. Platform-specific process argument handling remains owned by .NET, without invoking a shell.User-facing usage
On Windows, select WSLc with
ASPIRE_CONTAINER_RUNTIME=wslc. Single-platform .NET SDK publishing then uses WSLc's local store through the SDK's native support.Dockerfile publishing defaults to
linux/amd64; explicitly opt into the WSLc host platform only when appropriate:For a .NET SDK archive without container-file layering:
Validation
.\restore.cmd /p:SkipNativeBuild=true— passed during initial setup..\.dotnet\dotnet.exe test --project tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj --no-launch-profile /p:SkipNativeBuild=true -- --filter-class '*.WslcContainerRuntimeTests' --filter-class '*.ContainerRuntimeResolverTests' --filter-class '*.ContainerRuntimeDetectorTests' --filter-class '*.DockerContainerRuntimeTests' --filter-class '*.ContainerRuntimeBaseTests' --filter-class '*.DotnetProgramArchiveTests' --filter-class '*.DotnetProgramPublishingTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'— passed, 151 tests after mergingmain, before the argument-list correction..\.dotnet\dotnet.exe test --project tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj --no-launch-profile /p:SkipNativeBuild=true -- --filter-class '*.ContainerRuntimeBaseTests' --filter-class '*.DockerContainerRuntimeTests' --filter-class '*.PodmanSaveArgumentsTests' --filter-class '*.WslcContainerRuntimeTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'— passed, 95 tests after the argument-list correction and eager helper changes. The runtime-constant follow-up was rebuilt with--filter-method '*.BuildImageAsync_PreservesArgumentBoundaries'(same project and exclusions) — passed, 3 cases. The complete 95-test selection was rerun with--no-buildimmediately before pushing — passed..\.dotnet\dotnet.exe test --project tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj --no-build --no-launch-profile -- --filter-method '*.BuildSecretsFormats*' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'— passed, 4 tests after the argument-list correction..\.dotnet\dotnet.exe test --project tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj --no-build --no-launch-profile -- --filter-class '*.DotnetProgramArchiveTests' --filter-class '*.DotnetProgramPublishingTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'— passed, 48 tests after the argument-list correction..\.dotnet\dotnet.exe test --project tests\Aspire.Hosting.Tests\Aspire.Hosting.Tests.csproj --no-build --no-launch-profile -- --filter-method '*.BuildImageAsync_Dotnet*' --filter-method '*.BuildImageAsync_ProjectBuildPassesResolvedContainerRuntimeAsLocalRegistry' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'— passed, 20 tests after the SDK correction and before themainmerge..\.dotnet\dotnet.exe publish '<probe-directory>\probe.csproj' --configuration Release /t:PublishContainer --property:LocalRegistry=Wslc --property:ContainerRepository=aspire-wslc-sdk-probe-b35fa7a4 --property:ContainerImageTag=single --property:RuntimeIdentifier=linux-x64 --property:ContainerRuntimeIdentifier=linux-x64 --property:ContainerBaseImage=mcr.microsoft.com/dotnet/runtime:10.0 --source https://packagefeedproxy.microsoft.io/nuget/v3/index.json— passed using a temporary minimal net10.0 console project and SDK11.0.100-rc.1.26425.128. SDK reported successful publication via Wslc;wslc image inspect aspire-wslc-sdk-probe-b35fa7a4:single --format jsonconfirmed linux/amd64. Probe image and project cleaned up; the path above is a placeholder for that temporary directory.image inspect --format json; inspected tag/remove/push/login/build help and DCP's WSLc adapter. Direct--output type=dockerand--output type=ociprobes both failed with the Docker-driver exporter limitation, confirming the explicit archive boundary. Probe image/files cleaned up.System.Security.Cryptography.Pkcs10.0.12 remain; no dependency changes are included.Security considerations
The selected WSLc executable is trusted in the same way as Docker/Podman. Image commands use the existing process runner; registry passwords remain on stdin and environment build secrets follow the existing runtime pattern. Native image inspection uses source-generated JSON deserialization and preserves the image reference as a single process argument. Dockerfile build invocations for all three runtimes now preserve argument boundaries through
ProcessSpec.ArgumentList. No listener, elevated execution, archive extraction, or Aspire-managed archive/load bridge is added. A separate security review has not been performed.Fixes # (issue)
Checklist
<remarks />and<code />elements on your triple slash comments?