Skip to content

Modernize product process management APIs - #70669

Merged
adamsitnik merged 3 commits into
dotnet:mainfrom
adamsitnik:modernize-process-apis-product-improvements
Nov 20, 2026
Merged

adamsitnik merged 3 commits into
dotnet:mainfrom
adamsitnik:modernize-process-apis-product-improvements

Conversation

@adamsitnik

@adamsitnik adamsitnik commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Modernize product process management APIs

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Simplify product process management using modern .NET APIs.

Description

Product improvements split from dotnet/aspnetcore#70076, following review feedback. This branch starts directly from main, not from the product-fixes branch, and contains no non-shipping test/infrastructure changes. The test/infrastructure split is dotnet/aspnetcore#70668.

  • Use built-in output capture for project-ID resolution shared by user-secrets and user-jwts, removing custom event handlers and buffers.
  • Replace parent-process polling in the shipping Components.Testing package with exception-free lookup and asynchronous monitoring. Keep a wait API supporting Unix non-child processes.
  • Modernize Components.Testing exit waits, SPA shutdown-script status checks/diagnostics, certificate-command waiting, and dotnet-getdocument timeout waiting.
  • Configure explicit handle-inheritance lists for applicable shipping launch sites, permitting parallel Windows process creation and avoiding unintended inherited handles. Leave the modern shell-execution default unset where appropriate.
  • Simplify WebAssembly debug-proxy startup and cancellation-registration lifetime without changing live output/readiness protocols.

No measured throughput or binary-size improvement is claimed, and no shipping public API changes are introduced. Exit-status API substitutions are not presented as independently reproduced bug fixes. The SPA startup-status check retains its existing timing race.

Relationship to #70076: that PR (product bug fixes) has been merged, and this branch is merged with current main. The ParentProcessWatcher and SpaProxyLaunchManager changes here build on its Process wrapper disposal; for BaseCommand.cs (dotnet-openapi) this PR only adds the explicit handle-inheritance list.

This remains a real-world test of the process-api-net11 skill in dotnet/skills#1322.

Validation

Commands ran on Windows after . .\activate.ps1:

  • dotnet test src\Tools\dotnet-user-secrets\test\dotnet-user-secrets.Tests.csproj --no-restore -v:q -p:UseIisNativeAssets=false — 51 passed, 1 skipped.
  • dotnet test src\Tools\dotnet-user-jwts\test\dotnet-user-jwts.Tests.csproj -v:q -p:UseIisNativeAssets=false — 60 passed, 1 skipped.
  • dotnet test src\Middleware\Spa\SpaServices.Extensions\test\Microsoft.AspNetCore.SpaServices.Extensions.Tests.csproj -v:q -p:UseIisNativeAssets=false — 14 passed.
  • dotnet test src\Components\WebAssembly\Server\test\Microsoft.AspNetCore.Components.WebAssembly.Server.Tests.csproj -v:q -p:UseIisNativeAssets=false — 11 passed.
  • dotnet test src\Shared\test\Shared.Tests\Microsoft.AspNetCore.Shared.Tests.csproj -v:q -p:UseIisNativeAssets=false --filter 'FullyQualifiedName~Certificate' — 12 passed.
  • dotnet build src\Components\Testing\test\Microsoft.AspNetCore.Components.Testing.Tests.csproj -v:q -p:UseIisNativeAssets=false — passed.
  • dotnet run --project src\Components\Testing\test\Microsoft.AspNetCore.Components.Testing.Tests.csproj --no-build -- -class Microsoft.AspNetCore.Components.Testing.Tests.ServerInstanceTests -noLogo — 11 passed.
  • dotnet build src\Tools\dotnet-getdocument\src\dotnet-getdocument.csproj -v:q -p:UseIisNativeAssets=false — passed.
  • dotnet build src\Tools\Microsoft.dotnet-openapi\src\Microsoft.dotnet-openapi.csproj --no-restore -v:q -p:UseIisNativeAssets=false — passed.
  • dotnet build src\Middleware\Spa\SpaProxy\src\Microsoft.AspNetCore.SpaProxy.csproj -v:q -p:UseIisNativeAssets=false — passed.
  • dotnet build src\Tools\dotnet-dev-certs\src\dotnet-dev-certs.csproj -v:q -p:UseIisNativeAssets=false — passed.
  • dotnet build src\Tools\FirstRunCertGenerator\src\Microsoft.AspNetCore.DeveloperCertificates.XPlat.csproj -v:q -p:UseIisNativeAssets=false — passed.
  • git diff --check 49147673007a4b1d676694e2c5f85b83ad76c36f..HEAD — passed.
  • After merging main (with Fix product process-output hang and process-wrapper leaks #70076): dotnet build of Microsoft.dotnet-openapi, Microsoft.AspNetCore.SpaProxy, and Microsoft.AspNetCore.Components.Testing — passed; dotnet test src\Tools\Microsoft.dotnet-openapi\test\dotnet-microsoft.openapi.Tests.csproj -v:q -p:UseIisNativeAssets=false --filter 'FullyQualifiedName~OpenApiAddFileTests' — 11 passed.

The exact pinned SDK and unchanged-main JavaScript bundles were shared as local prerequisites; C# builds and outputs were isolated by worktree. macOS/Linux certificate operations and parent monitoring, Windows/macOS SPA shutdown scripts, NativeAOT size, and full browser E2E behavior were not runtime-validated.

Related issue: none linked.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 151a6a4b-fb9b-4efa-bb7c-383fe6bc3a4c
@adamsitnik
adamsitnik requested review from a team and BrennanConroy as code owners November 17, 2026 14:24
Copilot AI balanced review requested due to automatic review settings November 17, 2026 14:24
@github-actions github-actions Bot added area-blazor Includes: Blazor, Razor Components area-commandlinetools Includes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares labels Nov 17, 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.

🟢 Approval recommended

No active review issues remain for the process-management modernization changes.

No open issues 🎉

What changed in this PR

Modernizes process management in shipping ASP.NET Core tools and packages using newer .NET APIs. This is the product-modernization split; bug fixes and non-shipping infrastructure changes remain in separate PRs, with no public API changes introduced here.

Changes:

  • Replace custom output capture and selected process waits with built-in APIs.
  • Add explicit handle-inheritance lists at process launch sites.
  • Simplify parent monitoring and debug-proxy cancellation handling, and improve SPA shutdown-script diagnostics.
File Description
src/​Tools/​Shared/​SecretsHelpers/​ProjectIdResolver.cs Use built-in output capture for project-ID resolution.
src/​Tools/​Microsoft.dotnet-openapi/​src/​Commands/​BaseCommand.cs Set explicit handle inheritance for package commands.
src/​Tools/​dotnet-getdocument/​src/​Exe.cs Use timeout-aware exit-status waiting.
src/​Shared/​CertificateGeneration/​UnixCertificateManager.cs Set explicit handle inheritance for certificate commands.
src/​Shared/​CertificateGeneration/​MacOSCertificateManager.cs Modernize certificate-command waiting and handle inheritance.
src/​Middleware/​Spa/​SpaServices.Extensions/​src/​Npm/​NodeScriptRunner.cs Set explicit handle inheritance for Node script launches.
src/​Middleware/​Spa/​SpaProxy/​src/​SpaProxyLaunchManager.cs Update shutdown-script status checks and exit diagnostics.
src/​Components/​WebAssembly/​Server/​src/​DebugProxyLauncher.cs Simplify startup and cancellation-registration lifetime.
src/​Components/​Testing/​src/​Infrastructure/​ServerInstance.cs Modernize process launch and exit waits.
src/​Components/​Testing/​src/​Infrastructure/​ParentProcessWatcher.cs Replace polling with asynchronous parent-exit monitoring.

Review effort: Balanced

@PureWeen

Copy link
Copy Markdown
Member

/review

@adamsitnik adamsitnik left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've left comments, so other reviewers can understand the reasoning behind the changes and avoid similar issues in the future.

var parent = Process.GetProcessById(_parentPid);

while (!stoppingToken.IsCancellationRequested)
if (Process.TryGetProcessById(_parentPid, out var parent))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

to other code reviewers: We don't get exception of parent has already exited

// Also monitor for early process exit to fail fast with diagnostics.
var timeoutTask = Task.Delay(options.ReadinessTimeoutMs);
var processExitTask = _process.WaitForExitAsync();
var processExitTask = _process.WaitForExitStatusAsync();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

to other code reviewers: WaitForExitStatusAsync does not wait for the process to report EOF when std out/err are redirected (this is what WaitForExitAsync and friend do), which can avoid hangs when child process spawned other processes that keep the pipe opened

var stopProcess = Process.Start(stopScriptInfo);
if (stopProcess == null || stopProcess.HasExited)
var stopProcess = Process.Start(stopScriptInfo)!;
if (stopProcess.TryWaitForExitStatus(TimeSpan.Zero, out ProcessExitStatus? status))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

to other code reviewers: this check was and is still flaky (the process can fail a moment after the check). Copilot has just ported the code to the new API.

process.BeginOutputReadLine();
process.BeginErrorReadLine();
process.WaitForExit();
ProcessTextOutput processOutput = Process.RunAndCaptureText(psi);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

to other code reviewers: this is not only simpler but also WAY faster

environment,
appEntry.HarnessMode == E2EAppEntry.CompiledHarnessMode);

_process = Process.Start(startInfo)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

to other code reviewers: Process.Start can return null only when UseShellExecute is set to true, here it's not.

var startInfo = new ProcessStartInfo(executable, args)
{
UseShellExecute = false,
InheritedHandles = [],

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

to other code reviewers: this is what we recommend to always set. It makes the process inherit only std handles, without any other inheritable handles that are alive in the parent process. It also allows to spawn processes in parallel on Windows.


var startInfo = new ProcessStartInfo(executable, args)
{
UseShellExecute = false,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

to other code reviewers: UseShellExecute is set to false by default in modern .NET. When we don't set it at all, all the code related to it can be eliminated by the AOT compiler

Resolve conflicts with dotnet#70076 in ParentProcessWatcher and SpaProxyLaunchManager by keeping this branch's versions, which already include its process wrapper disposal.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 151a6a4b-fb9b-4efa-bb7c-383fe6bc3a4c
@adamsitnik
adamsitnik force-pushed the modernize-process-apis-product-improvements branch from 7033a73 to a6a076a Compare November 17, 2026 16:58
@PureWeen
PureWeen requested a balanced review from Copilot November 19, 2026 16:45
@PureWeen

Copy link
Copy Markdown
Member

/review

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.

🟢 Approval recommended

There are no active review issues blocking the process-management modernization.

No open issues 🎉

Review effort: Balanced

@PureWeen

Copy link
Copy Markdown
Member

Copilot's local review panel found no issues to raise at this commit.

All three independent arms (G/S/O) completed source review at a6a076abfb1d2db8e812b13d2a894a9a98bcfbf0. No verified, question, or unresolved finding remains. Hosted /review also completed with an explicit no-findings noop.

Informational discarded checks (non-blocking)

No candidate verifier was invoked: these were routine negative checks or worker questions settled by source inspection before verification. Existing explanatory author comments were deduplicated.

  • ServerInstance.cs:103,136: the exit-status wait and Process.ExitCode share process state; no conflicting exit-code result was established.
  • DebugProxyLauncher.cs:80-85: the cancellation registration remains active for the awaited launch and is disposed afterward.
  • ProjectIdResolver.cs:83,143: project IDs still come from the generated metadata file; removing text-buffer callbacks does not remove that producer.
  • dotnet-getdocument/Exe.cs:39-57: optional synchronous output reading already preceded the timeout; no new output-completion or timeout regression was established.
  • SDK availability: affected projects use the current target framework, and the new APIs are present in the pinned reference pack; the apparent older package-asset directory is not their compilation target.

Posted for informational purposes so the author can confirm the verifier didn't discard or leave unresolved a real finding; this item does not block agent-reviewed-approved.

Untested coverage gaps and scope limits

  • Existing environment/argument/artifact tests do not establish the changed subprocess lifecycle behavior; normal resolver success tests and Native AOT launch paths can bypass the changed edges.
  • Parent termination, readiness/early exit, stream lifetime, certificate commands, and SPA shutdown behavior were not runtime-validated by this panel across Windows/macOS/Linux.
  • SPA, certificate, and CLI changes received cross-cutting review, but no routed domain-specialist guide.

Validation boundary: all arms were source-only; O additionally inspected runtime primary source and the pinned reference pack, not the exact runtime build's implementation. No target code, tests, builds, or browser workflows were executed by the panel.

Human-directed and GitHub Copilot-generated.

@adamsitnik
adamsitnik merged commit 0328b91 into dotnet:main Nov 20, 2026
38 checks passed
@adamsitnik
adamsitnik deleted the modernize-process-apis-product-improvements branch November 20, 2026 12:34
@github-actions

Copy link
Copy Markdown
Contributor

✅ No documentation PR was created.

Confidence that documentation is needed: 8%

No docs needed: the change is internal refactoring of process management with no public API or documented behavior change.

Documentation surfaces considered

  • Conceptual article: Not required — Internal modernization of process APIs in shipping code; no user-visible behavior, API, or config change.
  • Migration guidance: Not required — No upgrade action for users.
  • Breaking change: Not required — No compatibility impact; PR states no shipping public API changes.

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — a6a076ab Deployed Nov 20, 2026 by adamsitnik via conclusion #413
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-reviewed-approved area-blazor Includes: Blazor, Razor Components area-commandlinetools Includes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants