Skip to content

Add platform-native local container CLI support - #55249

Merged
baronfel merged 14 commits into
dotnet:mainfrom
baronfel:baronfel-windows-container-tooling
Jul 21, 2026
Merged

baronfel merged 14 commits into
dotnet:mainfrom
baronfel:baronfel-windows-container-tooling

Conversation

@baronfel

@baronfel baronfel commented Jul 11, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds platform-native local container tooling and refactors local image loading so each runtime owns its behavior.

  • prefers Windows' native wslc CLI and macOS' native container CLI before Docker or Podman
  • falls back to Docker and then Podman when the platform-native runtime is unavailable
  • adds explicit Wslc and MacOSContainer values for the LocalRegistry MSBuild property
  • uses runtime-specific readiness probes, archive formats, load commands, manifest handling, and multi-platform behavior
  • supports WSLC local loads for single-platform images; multi-architecture local loads are rejected because WSLC does not support importing them
  • caches Docker, Podman, WSLC, and macOS container availability checks across tests
  • adds platform-gated end-to-end publish/load/run coverage for WSLC and the macOS container CLI

Fixes dotnet/sdk-container-builds#651
Fixes dotnet/sdk-container-builds#636

Review structure

The commits are ordered so each layer can be reviewed independently:

  1. removes the obsolete containerize CLI and its supporting infrastructure
  2. introduces the runtime abstraction and implements Docker and Podman through it
  3. adds WSLC detection, fallback, loading, telemetry, and tests
  4. adds native macOS container detection, fallback, loading, telemetry, and tests

Runtime architecture

  • introduces a behavioral IContainerRuntime abstraction for probing, availability, manifest selection, telemetry, and image loading
  • keeps runtime selection and fallback in a small ContainerRuntime facade
  • moves Docker- and Podman-specific behavior into their runtime implementations
  • separates shared process execution into ContainerRuntimeOperations and archive serialization into ContainerArchive
  • uses .NET 11 process handles and Process.RunAndCaptureTextAsync to stream archives to stdin while concurrently draining process output

Cleanup and compatibility

  • removes the obsolete standalone containerize CLI, its parser tests, package contents, Windows redist publishing, and CLI-only ContainerBuilder path
  • preserves the surviving image-format and user-ID helpers for the modern CreateNewImage task
  • removes obsolete container-specific crossgen handling
  • records the new KnownLocalRegistryTypes.MacOSContainer public API

The automatic runtime preference and removal of the packaged containerize executable are breaking changes. Documentation tracking: dotnet/docs#54761.

Testing

  • Microsoft.NET.Build.Containers.UnitTests: 284 total, 277 passed, 7 environment-gated skips
  • container package content tests: passed
  • EndToEndWithWslcLocalLoad: passed on Windows with WSLC
  • EndToEndMultiArch_WslcIsRejected: passed on Windows with WSLC
  • EndToEndWithMacOSContainerLocalLoad: platform- and environment-gated for macOS container tooling

Copilot AI review requested due to automatic review settings July 11, 2026 19:05
@baronfel
baronfel requested a review from a team as a code owner July 11, 2026 19:05
@baronfel
baronfel requested review from lbussell and mthalman July 11, 2026 19:07
@baronfel baronfel added Area-Containers Related to dotnet SDK containers functionality breaking-change Using this label will notify dotnet/compat and trigger a request to file a compat bug labels Jul 11, 2026
@dotnet-policy-service

dotnet-policy-service Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Added needs-breaking-change-doc-created label because this PR has the breaking-change label.

When you commit this breaking change:

  1. Create and link to this PR and the issue a matching issue in the dotnet/docs repo using the breaking change documentation template, then remove this needs-breaking-change-doc-created label.
  2. Ask a committer to mail the .NET SDK Breaking Change Notification email list.

You can refer to the .NET SDK breaking change guidelines

@baronfel baronfel assigned baronfel and unassigned mthalman and lbussell Jul 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the Containers feature area to prefer platform-native local container CLIs (Windows wslc, macOS container) ahead of Docker/Podman, adds explicit LocalRegistry types for them, and updates probing/load behavior and tests to match.

Changes:

  • Add Wslc and Container as explicit local registry types, and prefer them during local CLI detection (platform-gated).
  • Update local image load logic to use platform-native image load --input <tar> syntax (and force OCI output when using Apple container).
  • Add/adjust unit + integration test gating and caching of availability probes.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/Microsoft.NET.Build.Containers.UnitTests/DockerDaemonTests.cs Adds unit coverage for command selection, platform-gated probing, and platform-native load args/OCI forcing behavior.
test/Microsoft.NET.Build.Containers.UnitTests/DockerAvailableUtils.cs Caches Docker/Podman probe results for test-process lifetime and avoids probing platform-native CLIs in these attributes.
test/Microsoft.NET.Build.Containers.IntegrationTests/EndToEndTests.cs Adds platform-gated E2E publish/load/run tests for WSLC and Apple container.
test/Microsoft.NET.Build.Containers.IntegrationTests/DockerAvailableUtils.cs Adds new platform-native availability conditions and caches probe results for the test process.
test/Microsoft.NET.Build.Containers.IntegrationTests/ContainerCli.cs Switches CLI availability/podman detection to use cached status (Docker/Podman-focused).
src/Containers/packaging/build/Microsoft.NET.Build.Containers.targets Updates LocalRegistry comment to include Docker/Podman/Wslc/Container.
src/Containers/Microsoft.NET.Build.Containers/Telemetry.cs Adds telemetry classification for Wslc/Container (and Unknown) local storage types.
src/Containers/Microsoft.NET.Build.Containers/Tasks/CreateNewImage.cs Centralizes manifest media type selection via ContainerBuilder.GetManifestMediaType(...).
src/Containers/Microsoft.NET.Build.Containers/PublicAPI/net11.0/PublicAPI.Unshipped.txt Adds new public constants for KnownLocalRegistryTypes.Wslc and .Container.
src/Containers/Microsoft.NET.Build.Containers/LocalDaemons/KnownLocalRegistryTypes.cs Adds Wslc/Container registry types and expands supported list + factory mapping.
src/Containers/Microsoft.NET.Build.Containers/LocalDaemons/DockerCli.cs Implements platform-native probing, selection preference, and file-based image load --input support.
src/Containers/Microsoft.NET.Build.Containers/ContainerBuilder.cs Forces OCI manifest media type when destination local registry is Apple container.

@baronfel

Copy link
Copy Markdown
Member Author

Breaking-change documentation issue created: dotnet/docs#54761. A committer still needs to send the .NET SDK Breaking Change Notification email for this change.

@baronfel
baronfel marked this pull request as draft July 14, 2026 16:50
@baronfel
baronfel force-pushed the baronfel-windows-container-tooling branch from 1e87b49 to d6760ad Compare July 14, 2026 19:06
@baronfel
baronfel marked this pull request as ready for review July 14, 2026 19:10
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@baronfel

Copy link
Copy Markdown
Member Author

Ok @lbussell @mthalman I'm much happier with this pass. This is 4 commits that should be easier to review step by step:

  • remove the containerize binary, which was only used in the now-deleted .NET Framework Task implementation
  • refactor the container CLI handling to be plugin-based for easier extension and move the existing Docker and Podman support to that model
  • add wslc support
  • add macOS container support

Format the nested JSON objects so the Docker archive manifest structure is easier to scan.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 0489bafc-54c5-404d-b5ca-bde9210d4df0
baronfel added 3 commits July 20, 2026 14:40
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 856ddcdd-30dc-4a14-b19d-450af5d11be2
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 0489bafc-54c5-404d-b5ca-bde9210d4df0
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 0489bafc-54c5-404d-b5ca-bde9210d4df0
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 0489bafc-54c5-404d-b5ca-bde9210d4df0
@baronfel
baronfel enabled auto-merge (squash) July 20, 2026 22:24
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 0489bafc-54c5-404d-b5ca-bde9210d4df0
@baronfel

baronfel commented Jul 21, 2026 •

Copy link
Copy Markdown
Member Author

@lbussell can you take one more look? Had to add a change in this commit to make the data-based tests not report as a test failure on environments where no valid local container runtimes exist.

@baronfel

Copy link
Copy Markdown
Member Author

/ba-g stuck waiting for sdk-report-green, but that check has completed successfully already.

@baronfel
baronfel merged commit 993b505 into dotnet:main Jul 21, 2026
29 checks passed
@baronfel
baronfel deleted the baronfel-windows-container-tooling branch July 21, 2026 18:42
danegsta added a commit to microsoft/aspire that referenced this pull request Nov 6, 2026
…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 <[email protected]>
Copilot-Session: f85e4b06-371e-465a-8fd8-e635d14ec41f
Copilot-Session: b35fa7a4-1433-4b70-9840-5f5866230ff4
mitchdenny pushed a commit to microsoft/aspire that referenced this pull request Nov 10, 2026
…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 <[email protected]>
Copilot-Session: f85e4b06-371e-465a-8fd8-e635d14ec41f
Copilot-Session: b35fa7a4-1433-4b70-9840-5f5866230ff4
(cherry picked from commit 64ba1eb)
mitchdenny pushed a commit to microsoft/aspire that referenced this pull request Nov 10, 2026
…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 <[email protected]>
Copilot-Session: f85e4b06-371e-465a-8fd8-e635d14ec41f
Copilot-Session: b35fa7a4-1433-4b70-9840-5f5866230ff4
(cherry picked from commit 64ba1eb)
joperezr pushed a commit to microsoft/aspire that referenced this pull request Nov 11, 2026
…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 <[email protected]>
Copilot-Session: f85e4b06-371e-465a-8fd8-e635d14ec41f
Copilot-Session: b35fa7a4-1433-4b70-9840-5f5866230ff4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Containers Related to dotnet SDK containers functionality breaking-change Using this label will notify dotnet/compat and trigger a request to file a compat bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support new Windows container tooling Support new macOS container tooling

4 participants