Repository navigation
Simplify Aspire.Cli process code using .NET 11 Process APIs - #17079
Conversation
Use the new .NET 11 Preview 4 Process APIs to simplify process creation and output capture throughout src/Aspire.Cli: - Process.RunAndCaptureTextAsync for start+capture+wait patterns - Process.RunAndCaptureText for synchronous equivalents - Process.Run for fire-and-check-exit-code patterns - Process.ReadAllLinesAsync for line-by-line multiplexed streaming - File.OpenNullHandle() + StandardOutputHandle/StandardErrorHandle for null-device redirection - ProcessStartInfo.InheritedHandles for controlled handle inheritance The biggest win is DetachedProcessLauncher, where ~490 lines of platform-specific P/Invoke (Windows) and pipe-close workarounds (Unix) are replaced by a single cross-platform implementation. 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 -- 17079Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17079" |
|
I love this but lets not make anyone have to install .NET 11 previews to work on aspire 😄 |
Agreed. This is mostly exploratory and probably won't be merged anytime soon. Maybe when .NET 11 releases? |
Adam Sitnik (adamsitnik)
left a comment
There was a problem hiding this comment.
Eric Erhardt (@eerhardt) big thanks for giving the new API a try so quickly!!
Preserve main's process lifecycle, cancellation, and telemetry while retaining the Process API simplifications. Cover partial certificate output capture and keep stdin non-interactive through null handles. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d695e49d-5cf6-48f3-bc17-90538e743090
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Several migrations drop CreateNoWindow = true, and the PR description materially misstates the current scope.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 7
Open (8)
Preserve CreateNoWindow when launching processes · New Preserve CreateNoWindow when launching processes · New Preserve CreateNoWindow when launching processes · New Preserve CreateNoWindow when launching processes · New Preserve CreateNoWindow when launching processes · New Preserve CreateNoWindow when launching processes · New Preserve CreateNoWindow when launching processes · New Update PR description to match the revised scope · New
What changed in this PR
Modernizes remaining Aspire CLI process execution code with .NET 11 APIs while preserving custom cancellation and stream-handling behavior.
Changes:
- Replaces manual output capture with
RunAndCaptureText[Async]andReadAllTextAsync. - Uses null handles for non-interactive stdin and expands certificate process tests.
- Adds rationale for retaining platform-specific launch behavior; the PR description remains outdated.
| File | Description |
|---|---|
src/Aspire.Cli/Agents/ClaudeCode/ClaudeCodeCliRunner.cs |
Simplifies version capture. |
src/Aspire.Cli/Agents/Copilot/CopilotCliRunner.cs |
Simplifies version capture. |
src/Aspire.Cli/Agents/OpenCode/OpenCodeCliRunner.cs |
Simplifies version capture. |
src/Aspire.Cli/Agents/Playwright/PlaywrightCliRunner.cs |
Simplifies version and installation capture. |
src/Aspire.Cli/Agents/VsCode/VsCodeCliRunner.cs |
Simplifies version capture. |
src/Aspire.Cli/Certificates/CertificateGeneration/CertificateProcessRunner.cs |
Uses multiplexed output reading. |
src/Aspire.Cli/Certificates/CertificateHelpers.cs |
Uses synchronous process capture. |
src/Aspire.Cli/Commands/UpdateCommand.cs |
Simplifies updated-version detection. |
src/Aspire.Cli/DotNet/DotNetSdkInstaller.cs |
Multiplexes SDK command output. |
src/Aspire.Cli/Git/GitRepository.cs |
Multiplexes Git output while preserving tree cancellation. |
src/Aspire.Cli/Npm/NpmRunner.cs |
Uses null stdin and high-level output capture. |
src/Aspire.Cli/OpenCode/OpenCodeCliRunner.cs |
Simplifies legacy OpenCode version capture. |
src/Aspire.Cli/Processes/IsolatedProcess.Unix.cs |
Documents detached-launch constraints. |
src/Aspire.Cli/Processes/IsolatedProcess.Windows.cs |
Documents retained console isolation behavior. |
src/Aspire.Cli/Processes/IsolatedProcess.cs |
Replaces closed stdin pipes with a null handle. |
src/Aspire.Cli/Projects/DotNetBasedAppHostServerProject.cs |
Simplifies NuGet configuration discovery. |
src/Aspire.Cli/Utils/CliDownloader.cs |
Simplifies musl detection. |
src/Aspire.Cli/Utils/EnvironmentChecker/DeprecatedWorkloadCheck.cs |
Multiplexes workload command output. |
tests/Aspire.Cli.Tests/Certificates/CertificateProcessRunnerTests.cs |
Covers all output-redirection combinations. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Restore hidden-window options and conditional pipe waits where the one-shot text APIs are not equivalent. Use multiplexed byte capture with StreamReader BOM detection for paired output, and record npm process IDs immediately after launch. Add regression coverage for UTF-8/16/32 BOMs, per-stream and default encodings, partial stream redirection, and live npm profiling. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d695e49d-5cf6-48f3-bc17-90538e743090
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Cross-platform process lifecycle changes span several sensitive paths, and the PR is explicitly marked incomplete.
Review effort: Balanced
Findings: 1
Resolved since last review (7)
Preserve CreateNoWindow when launching processes Preserve CreateNoWindow when launching processes Preserve CreateNoWindow when launching processes Preserve CreateNoWindow when launching processes Preserve CreateNoWindow when launching processes Preserve CreateNoWindow when launching processes Preserve CreateNoWindow when launching processes
Use silent execution for non-interactive PowerShell certificate trust and stream SDK records with ReadAllLinesAsync. Bound OpenSSL capture and exit with process-tree cleanup, and give detached Windows children a valid null stdin handle. Add BOM, cancellation, and detached-stdin regression coverage. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d695e49d-5cf6-48f3-bc17-90538e743090
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. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Replace hand-rolled process plumbing in Aspire.Cli with the new .NET 11 System.Diagnostics.Process APIs: - IsolatedProcess: replace the custom Windows CreateProcessW launcher, WindowsConsoleProcessJob and most of WindowsProcessInterop with Process.Start using CreateNoWindow, KillOnParentExit, InheritedHandles and null std handles from File.OpenNullHandle. Detached Unix launches still go through DCP fork-process for PID handoff and exit monitoring. - One-shot probes (agent CLIs, update, downloader, certificates, git, npm, Deno, workload check, NuGet config) now use Process.RunAndCaptureText[Async] or Process.Run(silent: true). - Remove CertificateProcessRunner and ProcessOutputReader. - Comment the remaining sites that still need custom handling (tree-kill on cancel, capped output capture, stdout-only capture). - Harden AppHostServerSessionTests to use a long-running command that does not exit on EOF stdin. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d695e49d-5cf6-48f3-bc17-90538e743090
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The detached-Unix implementation contradicts the PR description’s claim that DCP launching remains unchanged.
Review effort: Balanced
Findings: 1
Open (1)
Resolved since last review (10)
Distinguish caller cancellation from process failure Do not report cancellation as OpenCode unavailable Do not swallow cancellation during npm operations Propagate cancellation returned by process execution Propagate cancellation during version probing Stop VS Code probing when cancellation occurs Do not swallow cancellation during playwright installation Do not swallow cancellation during OpenCode scanning Do not report cancellation as Copilot CLI unavailable Do not report cancellation as Claude Code unavailable
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
David Negstad (danegsta)
left a comment
There was a problem hiding this comment.
Found two process-abstraction correctness issues: one identity-environment leak in the self-update version probe and one process-tree cancellation gap in npm execution.
David Negstad (danegsta)
left a comment
There was a problem hiding this comment.
Added two process-abstraction comments: the agent version-probe family should use the injectable process-execution service, and the mutating Playwright installation path should retain centralized child-process policy.
David Negstad (danegsta)
left a comment
There was a problem hiding this comment.
One additional process-abstraction issue found.
David Negstad (danegsta)
left a comment
There was a problem hiding this comment.
Five additional direct-process abstraction issues found in the CLI scan.
- Give macOS `security verify-cert` and NSS certutil a null stdin. - Validate the minimum SDK version before launching `dotnet --list-sdks`. - Reuse IDotNetCliRunner.GetNuGetConfigPathsAsync in DotNetBasedAppHostServerProject instead of a second direct `dotnet nuget config paths` launch. - Use IEnvironment.RuntimeIdentifier for the CLI download RID, removing the `ldd --version` musl probe. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d695e49d-5cf6-48f3-bc17-90538e743090
This comment has been minimized.
This comment has been minimized.
Tests selector2 / 97 PR test projects · 4 PR jobs, from 47 changed files. Selected PR test projects (2 / 97)
Selected PR jobs (4)
How these were chosen — grouped by what changed📦 affected project 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 Job reasons
Selection computed for commit |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Cross-platform process lifetime, console, cancellation, and handle semantics warrant final human validation despite the focused regression coverage.
Review effort: Balanced
Findings: None
Resolved since last review (2)
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
PR Testing ReportPR Information
Artifact Version Verification
Changes AnalyzedChange Categories
Test Scenarios ExecutedScenario 1: CLI artifact and process-probe verificationObjective: Verify the dogfood artifact matches the PR head and process-based doctor probes complete successfully. Steps:
Evidence:
Observations:
Scenario 2: .NET AppHost detached lifecycleObjective: Exercise project creation, detached AppHost launch, redirected process output, dashboard child execution, discovery, and graceful shutdown. Steps:
Evidence:
Observations:
Scenario 3: TypeScript/npm AppHost detached lifecycleObjective: Exercise TypeScript project creation, npm-backed child processes, detached AppHost launch, resource discovery, and process-tree cleanup. Steps:
Evidence:
Observations:
Scenario 4: Nonexistent AppHostObjective: Verify invalid AppHost input fails safely without launching a process. Steps:
Evidence:
Expected Unhappy-Path Outcome: A clear validation error and non-zero exit code. Observations:
Supplemental Source ValidationThe core
CI already passed the broader PR test suite, so additional local source-test execution was not treated as a smoke-test gate. Summary
Overall Result✅ PR SMOKE TESTING VERIFIED The dogfood artifact behaved correctly across .NET and TypeScript AppHosts on macOS. The process changes successfully handled detached launch, output/resource discovery, graceful shutdown, npm-backed workloads, peer-install probing, and invalid AppHost input without leaving recorded child processes behind. |
|
✅ No documentation update needed. Step 5 branch taken: Triggered signals (3):
Allowlist justification: The PR's own checklist confirms "Did you add public API? No." No (summary truncated) |



Description
.NET 11 adds
System.Diagnostics.ProcessAPIs that cover most of the process plumbing Aspire.Cli used to write by hand (see https://devblogs.microsoft.com/dotnet/process-api-improvements-in-dotnet-11/). This PR moves the CLI onto those APIs and deletes the custom code they replace. Net change vsmain: 48 files, +803 / -3,924 lines.ProcessExecutionusesProcess.Startdirectly;IsolatedProcessis goneIsolatedProcess(all platforms),WindowsConsoleProcessJob, and nearly all ofWindowsProcessInterop. OnlySetConsoleCtrlHandlerremains, andProgram.csstill uses it.ProcessExecutionFactory.CreateProcessStartInfomaps the CLI launch options ontoProcessStartInfo:IsolateConsole/KillOnParentExit/Detached:CreateNoWindow = IsolateConsolegives the child its own hidden console for targeted CTRL+C.KillOnParentExitreplaces the hand-rolled kill-on-close job, assigned atomically at creation.InheritedHandles = []means the child inherits only the std handles.StartDetached(setsid) replaces the DCPfork-processlauncher, as Use DCP fork-process for Unix detached start #18678 anticipated. The child stays a direct child, so its PID and exit code are observable, and no bundle/layout lease is needed.ProcessExecutionreads output withProcess.ReadAllLinesAsync, soWaitForExitAsyncdoesn't wait on pipes a grandchild holds open.AgentTelemetryUploaderusesProcess.StartAndForget.dcp stop-process-treestill delivers CTRL+C to a child started withCreateNoWindow+KillOnParentExit+InheritedHandles = [].One-shot commands
RunAndCaptureText[Async]: the agent CLI version probes (Claude Code, Copilot, OpenCode, VS Code, Playwright),UpdateCommand,CertificateHelpers(5-second timeout), OpenSSL and macOSsecuritycalls,GitRepository,NpmRunner,DeprecatedWorkloadCheck, and the Deno version check.Process.Run(..., silent: true): WSL PowerShell trust and the macOS trust commands.ReadAllLinesAsync:DotNetSdkInstallerstreamsdotnet --list-sdks.CliDownloaderno longer runsldd --version. It detects musl fromRuntimeInformation.RuntimeIdentifier(viaIEnvironment), which NativeAOT sets to the publish RID.DotNetBasedAppHostServerProjectreusesIDotNetCliRunner.GetNuGetConfigPathsAsyncinstead of its owndotnet nuget config pathslaunch.CertificateProcessRunnerandProcessOutputReader, with their tests.Sites that keep custom code
Each has a comment explaining why the new APIs don't fit:
DotNetSdkInstallerandUnixCertificateManager.RunCertUtil: kill the whole process tree on cancel. The runtime helpers only kill the root process.ProcessCaptureRunner(PeerInstallProbe): caps output at 1 MiB per stream, kills the tree on timeout, and bounds the post-exit drain.MacOSCertificateManagerfind-certificate: captures stdout only.Follow-up
#20618 tracks routing the remaining direct
Processlaunches throughIProcessExecutionFactory. Those call sites already bypassed the factory onmain.Behavior changes to review
CREATE_NO_WINDOWinstead ofCREATE_NEW_CONSOLE | SW_HIDE. Both give the child its own hidden console./dev/nullstdin instead of a closed pipe. Both read as EOF.setsiddirectly instead of through DCPfork-process.ProcessExecutionstdout and stderr line callbacks are now serialized rather than concurrent.http_proxy/HTTP_PROXY) are passed through to children instead of being collapsed.AppHostServerSessionTestsnow usespinginstead ofcmd /c pauseas its long-running Windows command.pauseexits right away on EOF stdin, so the "still running" assertions raced under load.Validation
11.0.100-rc.1.26425.128.ProcessExecutionTests/ProcessExecutionDetachedTests:DotNetSdkInstaller,UnixCertificateManager,MacOSCertificateManagerandProcessExecutionDetachedtests: 46 passed, 7 skipped (non-Windows).AppHostServerProject,ScaffoldCache,ChannelResolution,AppHostServerSessionandCliDownloadertests: 45 passed, 1 failed. The failure is a Verify snapshot line-ending mismatch caused by CRLF files in my local checkout; this PR doesn't touch that snapshot.StartDetached, certificate managers) comes from CI.Checklist
<remarks />and<code />elements on your triple slash comments?