Skip to content

Backport fix for issue 15806 ( ("aspire stop" is not cleaning up application containers on Windows)#16123

Merged
joperezr merged 3 commits intorelease/13.2from
dev/karolz/issue-15806-backport
Apr 14, 2026
Merged

Backport fix for issue 15806 ( ("aspire stop" is not cleaning up application containers on Windows)#16123
joperezr merged 3 commits intorelease/13.2from
dev/karolz/issue-15806-backport

Conversation

@karolz-ms
Copy link
Copy Markdown
Contributor

Backporting fixes from #16006 and #16120

…ers) (#16006)

* Fix issue 15806

* Change default process start time check tolerance to 1 second

(to match the start time granularity used by the backchannel)

* Address code review feedback from Mitch

* Add ExecuteCommandUntilOutputAsync test helper

* Ensure containers are cleaned up by "aspire stop" command

* Improved check for container cleanup
# Conflicts:
#	src/Aspire.Cli/Program.cs
@github-actions
Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16123

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16123"

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Backports fixes related to aspire stop on Windows so that stopping a detached AppHost does not tear down DCP in a way that prevents container cleanup, and adds test coverage improvements to reduce flaky polling.

Changes:

  • Introduces a shared ProcessSignaler helper for start-time-guarded process lookup plus graceful shutdown / force-kill.
  • Updates stop/orphan-detection paths to rely on the shared process helper and include CLI start time in backchannel data.
  • Enhances CLI E2E start/stop tests with a helper that waits for expected command output and an additional cleanup assertion.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/Shared/Hex1bAutomatorTestHelpers.cs Adds a retrying “execute until output” helper used by E2E tests.
tests/Aspire.Cli.EndToEnd.Tests/StartStopTests.cs Uses unique project names and asserts post-stop cleanup via Docker network listing.
src/Shared/ProcessSignaler.cs New shared process signaling + start-time verification utility.
src/Aspire.Hosting/Cli/CliOrphanDetector.cs Replaces direct Process.GetProcessById checks with ProcessSignaler logic.
src/Aspire.Hosting/Backchannel/BackchannelDataTypes.cs Adds CliStartedAt to AppHostInformation for PID reuse protection.
src/Aspire.Hosting/Backchannel/AuxiliaryBackchannelRpcTarget.cs Plumbs ASPIRE_CLI_STARTED into AppHostInformation.CliStartedAt.
src/Aspire.Hosting/Aspire.Hosting.csproj Links in shared ProcessSignaler for Hosting.
src/Aspire.Cli/Program.cs Adds SIGTERM cancellation handling (non-Windows) and logs log-file path + PID.
src/Aspire.Cli/Processes/DetachedProcessLauncher.Windows.cs Adjusts Windows detached process creation flags for process-group signaling.
src/Aspire.Cli/Commands/StopCommand.cs Switches from killing process trees to graceful shutdown + targeted force-kill with start-time guard.
src/Aspire.Cli/Aspire.Cli.csproj Links in shared ProcessSignaler for CLI.

Comment thread src/Shared/ProcessSignaler.cs
Comment thread src/Aspire.Cli/Commands/StopCommand.cs
Comment thread tests/Aspire.Cli.EndToEnd.Tests/StartStopTests.cs
Comment thread src/Shared/ProcessSignaler.cs
Comment thread src/Shared/ProcessSignaler.cs
@github-actions
Copy link
Copy Markdown
Contributor

🎬 CLI E2E Test Recordings — 53 recordings uploaded (commit de08645)

View recordings
Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InitTypeScriptAppHost_AugmentsExistingViteRepoAtRoot ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View Recording
RunWithMissingAwaitShowsHelpfulError ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssets ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
TypeScriptAppHostWithProjectReferenceIntegration ▶️ View Recording

📹 Recordings uploaded automatically from CI run #24359447813

@joperezr joperezr added the Servicing-approved Approved for servicing release label Apr 14, 2026
@joperezr joperezr merged commit dff76b1 into release/13.2 Apr 14, 2026
267 checks passed
@github-actions github-actions bot added this to the 13.2.x milestone Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants