Skip to content

[release/11.0.2xx] Backport CLI cancellation handling from #56332 - #57228

Merged
baronfel merged 13 commits into
release/11.0.2xxfrom
baronfel-backport-cli-cancellation
Nov 23, 2026
Merged

baronfel merged 13 commits into
release/11.0.2xxfrom
baronfel-backport-cli-cancellation

Conversation

@baronfel

@baronfel baronfel commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Summary

Backports the complete merged change set from #56332, including its follow-up CI fixes, onto release/11.0.2xx.

This adds lifecycle-aware cancellation throughout the managed CLI and Native AOT paths while preserving the intended shutdown behavior:

  • The first Ctrl+C requests cooperative cancellation.
  • External child processes receive unlimited graceful shutdown time after the first Ctrl+C.
  • Repeated Ctrl+C forces termination.
  • Unix SIGTERM is forwarded with a bounded one-second child grace period.
  • Build and rollback operations can override the default soft-cancellation timeout.
  • Managed and Native AOT command paths use equivalent lifecycle semantics.

Release-branch adaptations

The release branch differs from the source PR, so conflicts were adapted instead of importing unrelated main-branch functionality:

  • Kept release-style Pack/Publish signatures without CommandServices.
  • Omitted unavailable MTP file-based AOT test-command and activity-telemetry plumbing while preserving cancellation in the release MTP implementation.
  • Added equivalent cancellation propagation to release-only tool-search and NuGet request APIs.
  • Removed main-only workload-update MSBuild server shutdown behavior that was inadvertently imported during the backport; cancellation-aware workload actions remain.
  • Preserved files already deleted or absent on the release branch.
  • Removed one unrelated main-only container authentication test whose product prerequisite is not present in this release.
  • After release/11.0.2xx advanced, merged the updated target branch and preserved both lifecycle cancellation and its newer VSTest artifact-directory behavior.

Review and CI follow-ups

  • Preserved cancellation through CLI command handlers that initially dropped the lifecycle token.
  • Applied the forwarded-MSBuild cancellation timeout and corrected its Unix lifecycle test host to use a managed assembly launched through dotnet exec.
  • Integrated MTP shutdown with the CLI lifecycle.
  • Forwarded Unix SIGTERM to every active MTP test process before applying one shared one-second grace period; repeated Ctrl+C still kills immediately.
  • Made MTP process startup and registration atomic with forceful shutdown, and synchronized unregister/disposal with termination so a child cannot escape during the race window.
  • Made SIGTERM forwarding tolerate each disposed or otherwise invalid process independently so one stale child cannot prevent signaling the remaining children.
  • Reported cancelled MTP runs with an otherwise-successful aggregate exit code as aborted instead of printing a false Passed! summary.
  • Converted internal Native AOT tool-search deadlines into graceful retryable failures while preserving caller-requested and unrelated cancellation.
  • Restored the release branch's independent ten-second Native AOT service-index discovery and query timeout budgets.
  • Removed the release-inapplicable workload MSBuild shutdown implementation and its tests.
  • Disabled NuGet audit only for SDK test child processes to prevent pinned prerelease advisory output from corrupting exact-output assertions.
  • Refreshed the flowed F# template approval.
  • Updated newly flowed JSON post-action, package-installation, and VSTest artifact-directory tests for the required cancellation-aware APIs.

Commits

  • c4f5ebfa65 Plumb cancellation through CLI commands and add phased shutdown (Plumb cancellation through CLI commands and add phased shutdown #56332)
  • b958af1f55 Remove main-only container auth test from backport
  • dd7eca2e29 Preserve cancellation through CLI command handlers
  • 44df4dd594 Honor the forwarded MSBuild cancellation timeout
  • c54de258ce Integrate MTP cancellation with the CLI lifecycle
  • b94d0e3fdf Fix forwarded MSBuild lifecycle test host
  • 78625c8895 Stabilize release branch test output
  • b458fa43f1 Merge release/11.0.2xx into cancellation backport
  • b7373e103e Preserve cancellation in flowed JSON post-action tests
  • eaa3d68bd8 Preserve cancellation in flowed package tests
  • 1bad8e5df9 Preserve cancellation signature in flowed VSTest tests
  • 657c04de3b Address cancellation review feedback
  • 85cb62a2f1 Fix cancellation shutdown races

Validation

  • Full Debug redist build passed.
  • Managed CLI and CLI utilities builds passed.
  • Focused cancellation, reporter, and tool-search tests: 73 passed.
  • Latest focused MTP manager and tool-search regression tests: 20 passed.
  • CLI process lifecycle tests: 4 passed, 13 Unix-only skipped on Windows.
  • Focused workload update test: 1 passed.
  • Native AOT CLI build and win-x64 publish passed.
  • Published Native AOT tool-command parser tests: 5 passed.
  • Native AOT pre-cancelled external-command coverage passed.
  • Virtual-project pre-cancellation test: 1 passed.
  • Template process/post-action tests: 17 passed.
  • Container registry/daemon tests: 57 passed, 7 environment-dependent skipped.
  • MSBuild consistency tests: 14 passed.
  • Template Engine sample tests: 16 passed.
  • Flowed JSON post-action tests: 47 passed.
  • Flowed package metadata-publication tests: 2 passed.
  • VSTest artifact-directory discovery tests: 5 passed.

CI is being monitored and failures are being addressed as individual legs report them.

Known validation limitation

The supported Windows dotnet run interruption test could not launch because the test application requires Microsoft.WindowsDesktop.App rc.2 while the repository bootstrap contains rc.1. The three Unix-only interruption cases were skipped on Windows. This is an environment/runtime mismatch rather than a backport compilation failure.

The existing NU1902/NU1903 warnings for pinned prerelease dependencies remain unchanged.

Copilot AI and others added 2 commits November 19, 2026 11:41
This applies cancellationtokens to all command callpaths, and uses those cancellation tokens to implement a two-phased shutdown, similar in intent to SIGINT vs SIGTERM in Unix.

The first Ctrl+C starts a soft-shutdown with a default limit of 200ms before forcibly shutting down. Most commands use this. A subsequent Ctrl+C/interrupt forcibly kills the command.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
# Conflicts:
#	.github/memory/ARCHITECTURE.md
#	src/Cli/dotnet-aot/NativeEntryPoint.cs
#	src/Cli/dotnet/Commands/Build/BuildCommand.cs
#	src/Cli/dotnet/Commands/Clean/CleanCommand.cs
#	src/Cli/dotnet/Commands/MSBuild/MSBuildCommand.cs
#	src/Cli/dotnet/Commands/Pack/PackCommand.cs
#	src/Cli/dotnet/Commands/Package/Add/PackageAddCommand.cs
#	src/Cli/dotnet/Commands/Publish/PublishCommand.cs
#	src/Cli/dotnet/Commands/Restore/RestoreCommand.cs
#	src/Cli/dotnet/Commands/Run/RunCommand.cs
#	src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs
#	src/Cli/dotnet/Commands/Test/AotTestCommand.cs
#	src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs
#	src/Cli/dotnet/Commands/Test/MTP/MicrosoftTestingPlatformTestCommand.cs
#	src/Cli/dotnet/Commands/Test/VSTest/TestCommand.cs
#	src/Cli/dotnet/Commands/Tool/Store/StoreCommand.cs
#	src/Cli/dotnet/Commands/Tool/ToolCommandParser.cs
#	src/Cli/dotnet/Commands/Workload/Install/WorkloadAdvertisingManifestUpdater.cs
#	src/Cli/dotnet/Commands/Workload/InstallingWorkloadCommand.cs
#	src/Cli/dotnet/Commands/Workload/Restore/WorkloadRestoreCommand.cs
#	src/Cli/dotnet/Commands/Workload/Search/WorkloadSearchVersionsCommand.cs
#	src/Cli/dotnet/Commands/Workload/WorkloadCommandParser.cs
#	src/Cli/dotnet/Parser.cs
#	src/Containers/AGENTS.md
#	src/Containers/Microsoft.NET.Build.Containers/Tasks/CreateNewImage.cs
#	test/Microsoft.DotNet.PackageInstall.Tests/NuGetPackageInstallerTests.cs
#	test/Microsoft.DotNet.Tools.Tests.ComponentMocks/MockNuGetPackageDownloader.cs
#	test/Microsoft.NET.Build.Containers.UnitTests/ImagePublisherTests.cs
#	test/Microsoft.NET.Build.Containers.UnitTests/RegistryTests.cs
#	test/Microsoft.TemplateEngine.Cli.UnitTests/PostActionTests/AddJsonPropertyPostActionTests.cs
#	test/dotnet.Tests/CommandTests/MSBuild/GivenCommandServices.cs
#	test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetPackInvocation.cs
#	test/dotnet.Tests/CommandTests/MSBuild/GivenDotnetPublishInvocation.cs
#	test/dotnet.Tests/CommandTests/MSBuild/MSBuildArgumentCommandLineParserTests.cs
#	test/dotnet.Tests/CommandTests/Pack/ReleasePropertyProjectLocatorTests.cs
#	test/dotnet.Tests/CommandTests/Test/VSTestArtifactDirectoryDiscoveryTests.cs
#	test/dotnet.Tests/CommandTests/Workload/Install/GivenWorkloadManifestUpdater.cs
#	test/dotnet.Tests/CommandTests/Workload/Restore/DiscoverAllProjectsTests.cs
#	test/dotnet.Tests/CommandTests/Workload/Search/GivenDotnetWorkloadSearch.cs
#	test/dotnet.Tests/CommandTests/Workload/Update/GivenDotnetWorkloadUpdate.cs
#	test/dotnet.Tests/TelemetryTests/MSBuildActivityTests.cs
The release branch does not include the unrelated auth exception filtering prerequisite. Keep the cancellation constructor updates without importing that main-only behavior.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@baronfel
baronfel requested review from a team, lbussell and mthalman as code owners November 19, 2026 18:17
Copilot AI balanced review requested due to automatic review settings November 19, 2026 18:17
@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
baronfel requested review from MiYanni and removed request for a team, lbussell and mthalman November 19, 2026 18:18
@baronfel baronfel added the Area-dotnet AOT Items that are part of the dotnet CLI AOT-ification effort label Nov 19, 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.

🟡 Changes recommended

Unresolved cancellation defects can leave forwarded MSBuild hanging indefinitely, terminate test cleanup prematurely, and misreport interrupted commands as failures or success.

6 open issues
What changed in this PR

Backports #56332’s cancellation handling to release/11.0.2xx, adapting command and helper APIs to the release branch. The changes connect CLI operations to lifecycle-aware cancellation and extend coverage across command execution, templates, workloads, and containers.

Changes:

  • Propagate cancellation tokens through command handlers, process execution, package operations, and supporting interfaces.
  • Add shutdown-timeout overrides for builds, rollback, and cleanup, plus signal-aware exit handling.
  • Update mocks and existing tests, and add cancellation regression tests and helper applications.
File Description
test/​TestAssets/​TestProjects/​WinExeApp/​Program.cs Adds configurable graceful-close delay.
test/​TemplateEngine/​Microsoft.TemplateEngine.Authoring.TemplateVerifier.UnitTests/​VerificationEngineTests.cs Updates cancellation-aware mocks.
test/​TemplateEngine/​Microsoft.TemplateEngine.Authoring.Tasks.IntegrationTests/​ValidateTemplatesTests.cs Passes test cancellation tokens.
test/​TemplateEngine/​Microsoft.TemplateEngine.Authoring.CLI.IntegrationTests/​VerifyCommandTests.cs Makes verification commands cancellable.
test/​TemplateEngine/​Microsoft.TemplateEngine.Authoring.CLI.IntegrationTests/​ValidateCommandTests.cs Passes test cancellation token.
test/​TemplateEngine/​Microsoft.TemplateEngine.Authoring.CLI.IntegrationTests/​ExportCommandFailureTests.cs Makes export commands cancellable.
test/​Microsoft.TemplateEngine.Cli.UnitTests/​PostActionTests/​ProcessStartPostActionProcessorTests.cs Tests post-action cancellation propagation.
test/​Microsoft.NET.TestFramework/​Commands/​TestCommand.cs Uses lifecycle tokens for execution and retries.
test/​Microsoft.NET.Publish.Tests/​PublishWpfApp.cs Makes published-app execution cancellable.
test/​Microsoft.NET.Publish.Tests/​PublishWebApp.cs Makes published-app execution cancellable.
test/​Microsoft.NET.Publish.Tests/​GivenThatWeWantToPublishTrimmedWindowsFormsAndWPFApps.cs Passes cancellation to desktop applications.
test/​Microsoft.NET.Build.Tests/​GivenThatWeWantToGenerateADepsFileForATool.cs Passes cancellation to tool execution.
test/​Microsoft.NET.Build.Tests/​AspNetCoreOnFullFramework.cs Passes cancellation to tool execution.
test/​Microsoft.NET.Build.Containers.UnitTests/​DockerAvailableUtils.cs Adapts runtime availability probes.
test/​Microsoft.NET.Build.Containers.IntegrationTests/​RegistryTests.cs Supplies registry cancellation token.
test/​Microsoft.NET.Build.Containers.IntegrationTests/​DockerSupportsArchHelper.cs Adapts Docker configuration probe.
test/​Microsoft.NET.Build.Containers.IntegrationTests/​DockerRegistryTests.cs Supplies registry and settings tokens.
test/​Microsoft.NET.Build.Containers.IntegrationTests/​DockerRegistryManager.cs Adapts registry setup APIs.
test/​Microsoft.NET.Build.Containers.IntegrationTests/​CreateNewImageTests.cs Supplies registry cancellation token.
test/​Microsoft.NET.Build.Containers.IntegrationTests/​CreateImageIndexTests.cs Supplies registry cancellation token.
test/​Microsoft.NET.Build.Containers.IntegrationTests/​ContainerCli.cs Adapts container-store probe.
test/​Microsoft.DotNet.Tools.Tests.ComponentMocks/​ToolPackageDownloaderMock2.cs Observes cancellation in download mock.
test/​Microsoft.DotNet.Tools.Tests.ComponentMocks/​ToolPackageDownloaderMock.cs Observes cancellation in installation mock.
test/​Microsoft.DotNet.Tools.Tests.ComponentMocks/​AppHostShellShimMakerMock.cs Updates shim mock contract.
test/​Microsoft.DotNet.PackageInstall.Tests/​ToolPackageUninstallerTests.cs Supplies installation cancellation token.
test/​Microsoft.DotNet.PackageInstall.Tests/​ToolPackageInstallerNugetCacheTests.cs Supplies installation cancellation tokens.
test/​Microsoft.DotNet.PackageInstall.Tests/​NuGetPackageInstallerExtractTests.cs Makes download and extraction cancellable.
test/​Microsoft.DotNet.PackageInstall.Tests/​MockFirstPartyNuGetPackageSigningVerifier.cs Observes cancellation in verifier mock.
test/​Microsoft.DotNet.Cli.Utils.Tests/​Microsoft.DotNet.Cli.Utils.Tests.csproj References lifecycle test application.
test/​Microsoft.DotNet.Cli.Utils.ProcessLifecycle.TestApp/​Microsoft.DotNet.Cli.Utils.ProcessLifecycle.TestApp.csproj Defines lifecycle test executable.
test/​dotnet.Tests/​ShellShimTests/​AppHostShellShimMakerTests.cs Passes cancellation to shim creation.
test/​dotnet.Tests/​ProgramTests.cs Tests pre-canceled external commands.
test/​dotnet.Tests/​NuGetPackageDownloaderTests.cs Adds package-query cancellation coverage.
test/​dotnet.Tests/​GivenExponentialRetry.cs Tests cancellation during retry delays.
test/​dotnet.Tests/​dotnet.Tests.csproj Adds helper reference and platform exclusion.
test/​dotnet.Tests/​CommandTests/​Workload/​Uninstall/​GivenDotnetWorkloadUninstall.cs Updates workload execution calls.
test/​dotnet.Tests/​CommandTests/​Workload/​Restore/​DiscoverAllProjectsTests.cs Passes discovery cancellation tokens.
test/​dotnet.Tests/​CommandTests/​Workload/​List/​GivenWorkloadInstallerAndWorkloadsInstalled.cs Updates list and update-query calls.
test/​dotnet.Tests/​CommandTests/​Workload/​Install/​WorkloadInstallAspireDeprecationTests.cs Updates installation execution calls.
test/​dotnet.Tests/​CommandTests/​Workload/​Install/​WorkloadGarbageCollectionTests.cs Passes garbage-collection cancellation tokens.
test/​dotnet.Tests/​CommandTests/​Workload/​Install/​MockWorkloadManifestUpdater.cs Updates cancellation-aware manifest mock.
test/​dotnet.Tests/​CommandTests/​Workload/​Install/​GivenAWindowsMsiManifestInstaller.cs Updates extraction mock and invocation.
test/​dotnet.Tests/​CommandTests/​Workload/​Install/​GivenAFileBasedManifestInstaller.cs Supplies extraction cancellation token.
test/​dotnet.Tests/​CommandTests/​Workload/​Clean/​GivenDotnetWorkloadClean.cs Updates workload execution calls.
test/​dotnet.Tests/​CommandTests/​Tool/​Update/​UpdateToolParserTests.cs Updates command execution signature.
test/​dotnet.Tests/​CommandTests/​Tool/​Uninstall/​ToolUninstallCommandTests.cs Updates command execution signatures.
test/​dotnet.Tests/​CommandTests/​Tool/​Search/​NugetSearchApiRequestTests.cs Supplies search cancellation tokens.
test/​dotnet.Tests/​CommandTests/​Tool/​Run/​ToolRunCommandTests.cs Tests pre-canceled tool execution.
test/​dotnet.Tests/​CommandTests/​Tool/​Restore/​ToolRestoreCommandWithMultipleNugetConfigTests.cs Updates restore execution signature.
test/​dotnet.Tests/​CommandTests/​Tool/​List/​ToolListLocalCommandTests.cs Updates local-list execution calls.
test/​dotnet.Tests/​CommandTests/​Tool/​List/​ToolListCommandTests.cs Updates list execution calls.
test/​dotnet.Tests/​CommandTests/​Tool/​Install/​InstallToolParserTests.cs Updates installation execution signature.
test/​dotnet.Tests/​CommandTests/​Solution/​List/​GivenDotnetSlnList.cs Tests canceled solution loading.
test/​dotnet.Tests/​CommandTests/​Sdk/​Check/​MockProductCollectionProvider.cs Updates cancellation-aware release-data mock.
test/​dotnet.Tests/​CommandTests/​Run/​RunCommandTests.cs Tests pre-canceled virtual-project builds.
test/​dotnet.Tests/​CommandTests/​Run/​GivenDotnetRunIsInterrupted.cs Exercises delayed Windows application shutdown.
test/​dotnet.Tests/​CommandTests/​Package/​List/​GivenDotnetListPackage.cs Tests restore cancellation propagation.
test/​dotnet.Tests/​CommandTests/​Pack/​ReleasePropertyProjectLocatorTests.cs Supplies discovery cancellation token.
test/​dotnet.Tests/​CommandTests/​NuGet/​GivenANuGetCommand.cs Tests token forwarding and pre-cancellation.
test/​dotnet.Tests/​CommandTests/​New/​DotnetRestorePostActionTests.cs Updates restore callback contract.
test/​dotnet.Tests/​CommandTests/​MSBuild/​MSBuildArgumentCommandLineParserTests.cs Updates publish command construction.
test/​dotnet.Tests/​CommandTests/​MSBuild/​GivenMsbuildForwardingApp.cs Tests pre-canceled MSBuild execution.
test/​dotnet.Tests/​CommandTests/​MSBuild/​GivenDotnetVsTestForwardingApp.cs Tests pre-canceled VSTest execution.
test/​dotnet.Tests/​CommandTests/​MSBuild/​GivenDotnetPublishInvocation.cs Supplies publish cancellation tokens.
test/​dotnet.Tests/​CommandTests/​MSBuild/​GivenDotnetPackInvocation.cs Supplies pack cancellation token.
test/​dotnet.Tests/​CommandTests/​CommandInvocationTests.cs Tests token delivery to command actions.
test/​dotnet.Tests/​BuildServerTests/​VBCSCompilerServerTests.cs Updates compiler-server shutdown tests.
test/​dotnet.Tests/​BuildServerTests/​RazorServerTests.cs Updates Razor-server shutdown tests.
test/​dotnet.Tests.TestApp/​RunApiTestApp.cs Adds blocked-input cancellation helper.
test/​dotnet.Tests.TestApp/​dotnet.Tests.TestApp.csproj Defines CLI test helper executable.
test/​dotnet-new.IntegrationTests/​CommonTemplatesTests.cs Makes permission-check command cancellable.
test/​dotnet-aot.Tests/​NativeEntryPointTests.cs Tests pre-canceled native external commands.
test/​ArgumentForwarding.Tests/​ArgumentForwardingTests.cs Supplies execution cancellation tokens.
src/​TemplateEngine/​Tools/​Shared/​Microsoft.TemplateEngine.CommandUtils/​TestCommand.cs Requires and forwards cancellation tokens.
src/​TemplateEngine/​Tools/​Shared/​Microsoft.TemplateEngine.CommandUtils/​Command.cs Adds cancellable child-process execution.
src/​TemplateEngine/​Tools/​Microsoft.TemplateSearch.TemplateDiscovery/​TemplateDiscoveryCommand.cs Forwards cancellation to cache tests.
src/​TemplateEngine/​Tools/​Microsoft.TemplateEngine.Authoring.TemplateVerifier/​VerificationEngine.cs Propagates cancellation to template commands.
src/​TemplateEngine/​Tools/​Microsoft.TemplateEngine.Authoring.TemplateVerifier/​Commands/​ICommandRunner.cs Requires command cancellation token.
src/​TemplateEngine/​Tools/​Microsoft.TemplateEngine.Authoring.TemplateVerifier/​Commands/​CommandRunner.cs Forwards command cancellation token.
src/​Containers/​Microsoft.NET.Build.Containers/​Telemetry.cs Makes runtime telemetry probes cancellable.
src/​Containers/​Microsoft.NET.Build.Containers/​Tasks/​CreateNewImage.cs Propagates task cancellation through setup.
src/​Containers/​Microsoft.NET.Build.Containers/​Tasks/​CreateImageIndex.cs Propagates task cancellation through setup.
src/​Containers/​Microsoft.NET.Build.Containers/​Registry/​RegistrySettings.cs Makes registry probing cancellable.
src/​Containers/​Microsoft.NET.Build.Containers/​LocalDaemons/​ILocalRegistry.cs Removes tokenless availability contract.
src/​Containers/​Microsoft.NET.Build.Containers/​LocalDaemons/​ArchiveFileRegistry.cs Removes synchronous availability method.
src/​Containers/​Microsoft.NET.Build.Containers/​DestinationImageReference.cs Passes cancellation to registry construction.
src/​Containers/​Microsoft.NET.Build.Containers/​ContainerHelpers.cs Makes manifest-format probing cancellable.
src/​Containers/​AGENTS.md Documents cancellation propagation requirements.
src/​Cli/​Microsoft.TemplateEngine.Cli/​TemplateInvoker.cs Passes cancellation to post-actions.
src/​Cli/​Microsoft.TemplateEngine.Cli/​PostActionProcessors/​PostActionProcessorBase.cs Extends post-action cancellation contract.
src/​Cli/​Microsoft.TemplateEngine.Cli/​PostActionProcessors/​IPostActionProcessor.cs Requires and documents cancellation token.
src/​Cli/​Microsoft.TemplateEngine.Cli/​PostActionProcessors/​InstructionDisplayPostActionProcessor.cs Adapts post-action signature.
src/​Cli/​Microsoft.TemplateEngine.Cli/​PostActionProcessors/​ChmodPostActionProcessor.cs Adapts post-action signature.
src/​Cli/​Microsoft.TemplateEngine.Cli/​PostActionProcessors/​AddJsonPropertyPostActionProcessor.cs Adapts post-action signature.
src/​Cli/​Microsoft.TemplateEngine.Cli/​IReporterExtensions.cs Reports captured command output.
src/​Cli/​Microsoft.DotNet.Cli.Utils/​NativeMethods.txt Adds Windows job-termination binding.
src/​Cli/​Microsoft.DotNet.Cli.Utils/​MSBuildForwardingAppWithoutLogging.cs Adds forwarded and in-process cancellation.
src/​Cli/​Microsoft.DotNet.Cli.Utils/​ICommand.cs Requires explicit execution cancellation.
src/​Cli/​Microsoft.DotNet.Cli.Utils/​ForwardingAppImplementation.cs Forwards execution cancellation token.
src/​Cli/​Microsoft.DotNet.Cli.Utils/​Extensions/​ProcessStartInfoExtensions.cs Routes execution through cancellable commands.
src/​Cli/​Microsoft.DotNet.Cli.Utils/​Extensions/​LockFileFormatExtensions.cs Makes lock acquisition cancellable.
src/​Cli/​Microsoft.DotNet.Cli.Utils/​ExponentialRetry.cs Makes retry delays cancellable.
src/​Cli/​Microsoft.DotNet.Cli.Utils/​BuiltInCommand.cs Rejects pre-canceled execution.
src/​Cli/​Microsoft.DotNet.Cli.CommandLine/​CommandExtensions.cs Adapts synchronous token-aware actions.
src/​Cli/​dotnet/​TransactionalAction.cs Suspends automatic timeout during rollback.
src/​Cli/​dotnet/​ToolPackage/​ToolPackageDownloader.cs Propagates download, hashing, and extraction cancellation.
src/​Cli/​dotnet/​ToolPackage/​IToolPackageDownloader.cs Requires installation cancellation token.
src/​Cli/​dotnet/​ToolPackage/​IProjectRestorer.cs Requires restore cancellation token.
src/​Cli/​dotnet/​ShellShim/​ShellShimTemplateFinder.cs Makes apphost retrieval cancellable.
src/​Cli/​dotnet/​ShellShim/​ShellShimRepository.cs Passes cancellation through shim creation.
src/​Cli/​dotnet/​ShellShim/​IShellShimRepository.cs Requires shim cancellation token.
src/​Cli/​dotnet/​ShellShim/​IApphostShellShimMaker.cs Updates apphost shim contract.
src/​Cli/​dotnet/​ShellShim/​AppHostShimMaker.cs Passes cancellation to permission setting.
src/​Cli/​dotnet/​ReleasePropertyProjectLocator.cs Makes solution discovery cancellable.
src/​Cli/​dotnet/​Parser.cs Delegates signal ownership and tokenizes help execution.
src/​Cli/​dotnet/​NugetSearch/​INugetToolSearchApiRequest.cs Requires search cancellation token.
src/​Cli/​dotnet/​NugetPackageDownloader/​INuGetPackageDownloader.cs Requires package-operation cancellation tokens.
src/​Cli/​dotnet/​NugetPackageDownloader/​IFirstPartyNuGetPackageSigningVerifier.cs Requires verification cancellation token.
src/​Cli/​dotnet/​NuGetForwardingApp.cs Forwards NuGet cancellation token.
src/​Cli/​dotnet/​IFilePermissionSetter.cs Requires permission-operation cancellation tokens.
src/​Cli/​dotnet/​ICommandRunner.cs Requires command cancellation token.
src/​Cli/​dotnet/​ForwardingApp.cs Forwards execution cancellation token.
src/​Cli/​dotnet/​FirstRunExperience.cs Preserves cancellation exceptions.
src/​Cli/​dotnet/​FilePermissionSetter.cs Makes chmod execution cancellable.
src/​Cli/​dotnet/​dotnet.csproj Grants test helper internal access.
src/​Cli/​dotnet/​Commands/​Workload/​WorkloadManifestCorruptionRepairer.cs Supplies lifecycle token to repairs.
src/​Cli/​dotnet/​Commands/​Workload/​WorkloadIntegrityChecker.cs Supplies lifecycle token to installation.
src/​Cli/​dotnet/​Commands/​Workload/​Uninstall/​WorkloadUninstallCommand.cs Passes cancellation to garbage collection.
src/​Cli/​dotnet/​Commands/​Workload/​Search/​WorkloadSearchCommand.cs Adapts command execution signature.
src/​Cli/​dotnet/​Commands/​Workload/​Restore/​WorkloadRestoreCommand.cs Propagates discovery and installation cancellation.
src/​Cli/​dotnet/​Commands/​Workload/​Repair/​WorkloadRepairCommand.cs Propagates cancellation through repair operations.
src/​Cli/​dotnet/​Commands/​Workload/​List/​WorkloadListCommand.cs Makes update queries cancellable.
src/​Cli/​dotnet/​Commands/​Workload/​Install/​WorkloadManifestUpdater.Managed.cs Propagates manifest-operation cancellation.
src/​Cli/​dotnet/​Commands/​Workload/​Install/​WorkloadManifestUpdater.cs Makes background updates cancellation-aware.
src/​Cli/​dotnet/​Commands/​Workload/​Install/​WindowsMsiManifestInstaller.cs Passes cancellation to package extraction.
src/​Cli/​dotnet/​Commands/​Workload/​Install/​MsiInstallerBase.cs Makes dependency updates overridable for testing.
src/​Cli/​dotnet/​Commands/​Workload/​Install/​IWorkloadManifestUpdater.cs Requires manifest-operation cancellation tokens.
src/​Cli/​dotnet/​Commands/​Workload/​Install/​IWorkloadManifestInstaller.cs Requires extraction cancellation token.
src/​Cli/​dotnet/​Commands/​Workload/​Install/​IInstaller.cs Adds cancellation to installer contracts.
src/​Cli/​dotnet/​Commands/​Workload/​Install/​FileBasedManifestInstaller.cs Checks and forwards extraction cancellation.
src/​Cli/​dotnet/​Commands/​Workload/​History/​WorkloadHistoryCommand.cs Adapts command execution signature.
src/​Cli/​dotnet/​Commands/​Workload/​Elevate/​WorkloadElevateCommand.cs Adapts command execution signature.
src/​Cli/​dotnet/​Commands/​Workload/​Config/​WorkloadConfigCommand.cs Adapts command execution signature.
src/​Cli/​dotnet/​Commands/​Workload/​Clean/​WorkloadCleanCommand.cs Makes garbage collection cancellable.
src/​Cli/​dotnet/​Commands/​VSTest/​VSTestCommandParser.cs Wires token-aware VSTest action.
src/​Cli/​dotnet/​Commands/​VSTest/​VSTestCommand.cs Propagates execution and post-processing cancellation.
src/​Cli/​dotnet/​Commands/​Tool/​Update/​ToolUpdateLocalCommand.cs Forwards cancellation to local installation.
src/​Cli/​dotnet/​Commands/​Tool/​Update/​ToolUpdateGlobalOrToolPathCommand.cs Uses caller token for updates.
src/​Cli/​dotnet/​Commands/​Tool/​Update/​ToolUpdateCommand.cs Propagates cancellation through update dispatch.
src/​Cli/​dotnet/​Commands/​Tool/​Uninstall/​ToolUninstallLocalCommand.cs Adapts command execution signature.
src/​Cli/​dotnet/​Commands/​Tool/​Uninstall/​ToolUninstallGlobalOrToolPathCommand.cs Adapts command execution signature.
src/​Cli/​dotnet/​Commands/​Tool/​Uninstall/​ToolUninstallCommand.cs Forwards cancellation through uninstall dispatch.
src/​Cli/​dotnet/​Commands/​Tool/​Store/​StoreCommand.cs Passes cancellation to store execution.
src/​Cli/​dotnet/​Commands/​Tool/​Search/​ToolSearchCommand.cs Makes search requests cancellable.
src/​Cli/​dotnet/​Commands/​Tool/​Run/​ToolRunCommand.cs Makes local-tool execution cancellable.
src/​Cli/​dotnet/​Commands/​Tool/​Restore/​ToolRestoreCommand.cs Uses caller token for restore.
src/​Cli/​dotnet/​Commands/​Tool/​Restore/​ToolPackageRestorer.cs Passes cancellation to package installation.
src/​Cli/​dotnet/​Commands/​Tool/​List/​ToolListLocalCommand.cs Adapts command execution signature.
src/​Cli/​dotnet/​Commands/​Tool/​List/​ToolListGlobalOrToolPathCommand.cs Adapts command execution signature.
src/​Cli/​dotnet/​Commands/​Tool/​List/​ToolListCommand.cs Forwards cancellation through list dispatch.
src/​Cli/​dotnet/​Commands/​Tool/​Install/​ToolInstallLocalInstaller.cs Makes local package installation cancellable.
src/​Cli/​dotnet/​Commands/​Tool/​Install/​ToolInstallGlobalOrToolPathCommand.cs Propagates installation and shim cancellation.
src/​Cli/​dotnet/​Commands/​Tool/​Install/​ToolInstallCommand.cs Forwards cancellation through installation dispatch.
src/​Cli/​dotnet/​Commands/​Tool/​Install/​ProjectRestorer.cs Makes restore command execution cancellable.
src/​Cli/​dotnet/​Commands/​Tool/​Execute/​ToolExecuteCommand.cs Propagates installation and execution cancellation.
src/​Cli/​dotnet/​Commands/​Test/​TestCommandParser.cs Passes cancellation to MTP command.
src/​Cli/​dotnet/​Commands/​Test/​MTP/​TestModulesFilterHandler.cs Adapts initialization contract.
src/​Cli/​dotnet/​Commands/​Test/​MTP/​MSBuildHandler.cs Makes project preparation cancellable.
src/​Cli/​dotnet/​Commands/​Test/​MTP/​MicrosoftTestingPlatformTestCommand.Help.cs Uses lifecycle token for help execution.
src/​Cli/​dotnet/​Commands/​Test/​MTP/​MicrosoftTestingPlatformTestCommand.cs Passes cancellation to test initialization.
src/​Cli/​dotnet/​Commands/​Test/​MTP/​ITestHandler.cs Requires initialization cancellation token.
src/​Cli/​dotnet/​Commands/​Solution/​SolutionCommandParser.cs Wires token-aware solution actions.
src/​Cli/​dotnet/​Commands/​Solution/​Migrate/​SolutionMigrateCommand.cs Makes solution conversion cancellable.
src/​Cli/​dotnet/​Commands/​Solution/​List/​SolutionListCommand.cs Preserves solution-loading cancellation.
src/​Cli/​dotnet/​Commands/​Sdk/​SdkCommandParser.cs Imports token-aware action extension.
src/​Cli/​dotnet/​Commands/​Sdk/​Check/​SdkOutputWriter.cs Passes cancellation to release queries.
src/​Cli/​dotnet/​Commands/​Sdk/​Check/​SdkCheckCommand.cs Propagates SDK-check cancellation.
src/​Cli/​dotnet/​Commands/​Sdk/​Check/​RuntimeOutputWriter.cs Accepts output-operation cancellation token.
src/​Cli/​dotnet/​Commands/​Sdk/​Check/​ProductCollectionProvider.cs Makes release-data waits cancellable.
src/​Cli/​dotnet/​Commands/​Sdk/​Check/​IProductCollectionProvider.cs Requires release-query cancellation tokens.
src/​Cli/​dotnet/​Commands/​Sdk/​Check/​BundleOutputWriter.cs Retains cancellation token for queries.
src/​Cli/​dotnet/​Commands/​Run/​CSharpCompilerCommand.cs Propagates compiler cancellation.
src/​Cli/​dotnet/​Commands/​Run/​Api/​RunApiCommandParser.cs Wires token-aware run-api action.
src/​Cli/​dotnet/​Commands/​Run/​Api/​RunApiCommand.cs Adds cancellable standard-input waiting.
src/​Cli/​dotnet/​Commands/​Restore/​RestoreCommand.cs Passes cancellation to restore execution.
src/​Cli/​dotnet/​Commands/​Reference/​Remove/​ReferenceRemoveCommand.cs Adapts command execution signature.
src/​Cli/​dotnet/​Commands/​Reference/​ReferenceCommandParser.cs Wires token-aware reference actions.
src/​Cli/​dotnet/​Commands/​Reference/​List/​ReferenceListCommand.cs Adapts command execution signature.
src/​Cli/​dotnet/​Commands/​Reference/​Add/​ReferenceAddCommand.cs Adapts command execution signature.
src/​Cli/​dotnet/​Commands/​Publish/​PublishCommand.cs Propagates discovery and execution cancellation.
src/​Cli/​dotnet/​Commands/​Project/​ProjectCommandParser.cs Wires token-aware conversion action.
src/​Cli/​dotnet/​Commands/​Project/​Convert/​ProjectConvertCommand.cs Rejects pre-canceled conversion.
src/​Cli/​dotnet/​Commands/​Package/​Search/​PackageSearchCommand.cs Passes cancellation to NuGet search.
src/​Cli/​dotnet/​Commands/​Package/​Remove/​PackageRemoveCommand.cs Passes cancellation to NuGet removal.
src/​Cli/​dotnet/​Commands/​Package/​List/​PackageListCommand.cs Propagates restore and listing cancellation.
src/​Cli/​dotnet/​Commands/​Package/​Add/​PackageAddCommand.cs Propagates cancellation and adds temporary-file cleanup.
src/​Cli/​dotnet/​Commands/​Pack/​PackCommand.cs Propagates discovery and execution cancellation.
src/​Cli/​dotnet/​Commands/​NuGet/​NuGetCommandParser.cs Imports token-aware action extension.
src/​Cli/​dotnet/​Commands/​New/​PostActions/​DotnetRestorePostActionProcessor.cs Passes cancellation through restore callbacks.
src/​Cli/​dotnet/​Commands/​MSBuild/​MSBuildForwardingApp.cs Adds build-specific shutdown timeout.
src/​Cli/​dotnet/​Commands/​MSBuild/​MSBuildCommandParser.cs Imports token-aware action extension.
src/​Cli/​dotnet/​Commands/​MSBuild/​MSBuildCommand.cs Passes cancellation to MSBuild execution.
src/​Cli/​dotnet/​Commands/​Hidden/​Remove/​RemoveCommandParser.cs Wires token-aware legacy remove actions.
src/​Cli/​dotnet/​Commands/​Hidden/​List/​ListCommandParser.cs Wires token-aware legacy list actions.
src/​Cli/​dotnet/​Commands/​Hidden/​Add/​AddCommandParser.cs Wires token-aware legacy reference action.
src/​Cli/​dotnet/​Commands/​Fsi/​FsiCommandParser.cs Wires token-aware FSI action.
src/​Cli/​dotnet/​Commands/​Fsi/​FsiCommand.cs Passes cancellation to FSI execution.
src/​Cli/​dotnet/​Commands/​Format/​FormatCommandParser.cs Wires token-aware format action.
src/​Cli/​dotnet/​Commands/​Format/​FormatCommand.cs Passes cancellation to formatter execution.
src/​Cli/​dotnet/​Commands/​Clean/​FileBasedAppArtifacts/​CleanFileBasedAppArtifactsCommand.cs Adapts command execution signature.
src/​Cli/​dotnet/​Commands/​Clean/​CleanCommandParser.cs Wires token-aware artifact-cleaning action.
src/​Cli/​dotnet/​Commands/​Clean/​CleanCommand.cs Passes cancellation to clean execution.
src/​Cli/​dotnet/​Commands/​BuildServer/​BuildServerCommandParser.cs Wires token-aware shutdown action.
src/​Cli/​dotnet/​Commands/​Build/​BuildCommand.cs Passes cancellation to build execution.
src/​Cli/​dotnet/​CommandInvocation.cs Invokes token-aware actions and maps signal cancellation.
src/​Cli/​dotnet/​CommandFactory/​CommandResolution/​ProjectToolsCommandResolver.cs Makes lock waits and dependency generation cancellable.
src/​Cli/​dotnet/​CommandFactory/​CommandResolution/​MSBuildProject.cs Uses lifecycle token for lock-file reads.
src/​Cli/​dotnet/​CommandBase.cs Requires explicit execution cancellation.
src/​Cli/​dotnet/​CliTransaction.cs Suspends automatic timeout during rollback and cleanup.
src/​Cli/​dotnet/​BuildServer/​VBCSCompilerServer.cs Makes compiler-server shutdown cancellable.
src/​Cli/​dotnet/​BuildServer/​RazorServer.cs Makes Razor-server shutdown cancellable.
src/​Cli/​dotnet/​BuildServer/​MSBuildServer.cs Checks cancellation around node shutdown.
src/​Cli/​dotnet/​BuildServer/​IBuildServer.cs Requires shutdown cancellation token.

Review effort: Balanced

baronfel and others added 3 commits November 19, 2026 12:51
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use the managed lifecycle test app as the fake MSBuild assembly so MSBuild forwarding launches it through dotnet exec on Unix.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Disable NuGet audit in SDK test child processes and refresh the F# sample approval to match the current in-repo template.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
baronfel and others added 4 commits November 19, 2026 20:57
Preserve lifecycle cancellation through the updated VSTest artifact-directory handling and command help paths.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Pass the MSTest cancellation token to test cases added by the release branch merge.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Thread the MSTest cancellation token through package publication and cache helper paths added by the release branch merge.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

@MiYanni MiYanni left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copilot noticed a few things that are different in the backport.


Most of #56332 matches, but I found four concerns:

  • MTP SIGTERM handling kills test processes immediately instead of forwarding SIGTERM with the promised grace period.
  • MTP reporting can print “Passed” for an interrupted partial run while returning 130.
  • Tool search reports an AOT service-index timeout as an unhandled exception rather than a retriable error.
  • Workload update also imports #56116, which was absent from the release branch. Its server shutdown is skipped after cancellation because it receives the canceled token; that defect is inherited from the source PR.

Forward SIGTERM through MTP test processes with bounded grace, report cancelled successful runs as aborted, translate Native AOT tool-search deadlines into graceful retryable failures, and remove unrelated workload server shutdown behavior from the release backport.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@baronfel

baronfel commented Nov 20, 2026 •

Copy link
Copy Markdown
Member Author

@MiYanni Addressed all four concerns in 657c04de3b:

  • MTP now forwards SIGTERM to all active test processes, gives them one shared one-second grace period, then kills survivors; repeated Ctrl+C remains immediate.
  • Cancelled MTP runs whose aggregate result is still zero are reported as aborted rather than Passed!.
  • Tool-search internal deadlines become graceful retryable failures, while caller-requested and unrelated cancellation still propagate.
  • The main-only workload MSBuild server shutdown behavior and its tests were removed from this release backport.

Added focused regression coverage for each behavior. Managed cancellation/reporter/tool-search tests pass (73 total), process lifecycle tests pass on Windows with the Unix SIGTERM case queued for CI, and the Native AOT CLI build/publish plus focused published AOT tests pass.

@baronfel

Copy link
Copy Markdown
Member Author

/azp run sdk-report-green

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@MiYanni MiYanni left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like Copilot has 3 other concerns.

  1. ❌ High confidence — SIGTERM cleanup can skip every child. A process can be disposed after the manager snapshots it; the unguarded HasExited check then throws before any children are signaled. Handle disposed processes individually.

  2. ❌ High confidence — child startup can race shutdown. SIGTERM or a second Ctrl+C can arrive between starting and registering a test process. The parent can exit with an empty snapshot, leaving that child running. Coordinate startup and shutdown.

  3. ⚠️ High confidence — tool search still has a shorter timeout. The shared ten-second deadline covers both index discovery and search; the release baseline gave AOT each stage ten seconds. Restore separate budgets to avoid failing previously successful slow requests.

Double checked to make sure they're specific to the backport, compared to main.

image

Coordinate MTP process startup with forceful shutdown, tolerate disposed processes during SIGTERM forwarding, and restore independent Native AOT tool-search timeout budgets.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@baronfel

Copy link
Copy Markdown
Member Author

Addressed all three latest concerns in 85cb62a: ProcessReaper now handles disposed/invalid children independently so one stale process cannot abort SIGTERM forwarding; MTP process startup/registration, forceful shutdown, and unregister/disposal now share one synchronization boundary so a child cannot escape the shutdown snapshot; and Native AOT tool search again gets separate ten-second service-index and query timeout budgets. Added focused regression coverage for each case. Latest local validation: 20/20 MTP manager + tool-search tests passed, 4 process-lifecycle tests passed with 13 Unix-only cases skipped on Windows, and the published Native AOT parser suite passed 5/5.

@MiYanni MiYanni left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

:shipit:

@baronfel
baronfel enabled auto-merge November 23, 2026 18:28
@baronfel
baronfel merged commit 964e2c0 into release/11.0.2xx Nov 23, 2026
23 checks passed
@baronfel
baronfel deleted the baronfel-backport-cli-cancellation branch November 23, 2026 23:21

This branch had an error being deployed

1 failed deployment
copilot-pat-pool — 85cb62a2 Deployed Nov 23, 2026 by baronfel via pre_activation #15819
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-CLI Area-dotnet AOT Items that are part of the dotnet CLI AOT-ification effort

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants