Repository navigation
[release/11.0.2xx] Backport CLI cancellation handling from #56332 - #57228
Conversation
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>
|
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. |
There was a problem hiding this comment.
🟡 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
MSBuild forwarding can hang indefinitely after Ctrl+C · New Template invocation reports cancellation as a failure · New RestoreProject swallows post-action cancellation · New run-api reports success after Ctrl+C · New MTP test runs bypass the lifecycle shutdown deadline · New Uninstall wraps cancellation as a failure · New
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
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>
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
left a comment
There was a problem hiding this comment.
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>
|
@MiYanni Addressed all four concerns in
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. |
|
/azp run sdk-report-green |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
MiYanni
left a comment
There was a problem hiding this comment.
Looks like Copilot has 3 other concerns.
-
❌ High confidence — SIGTERM cleanup can skip every child. A process can be disposed after the manager snapshots it; the unguarded
HasExitedcheck then throws before any children are signaled. Handle disposed processes individually. -
❌ 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.
-
⚠️ 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.
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>
|
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. |


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:
Release-branch adaptations
The release branch differs from the source PR, so conflicts were adapted instead of importing unrelated main-branch functionality:
CommandServices.release/11.0.2xxadvanced, merged the updated target branch and preserved both lifecycle cancellation and its newer VSTest artifact-directory behavior.Review and CI follow-ups
dotnet exec.Passed!summary.Commits
c4f5ebfa65Plumb cancellation through CLI commands and add phased shutdown (Plumb cancellation through CLI commands and add phased shutdown #56332)b958af1f55Remove main-only container auth test from backportdd7eca2e29Preserve cancellation through CLI command handlers44df4dd594Honor the forwarded MSBuild cancellation timeoutc54de258ceIntegrate MTP cancellation with the CLI lifecycleb94d0e3fdfFix forwarded MSBuild lifecycle test host78625c8895Stabilize release branch test outputb458fa43f1Merge release/11.0.2xx into cancellation backportb7373e103ePreserve cancellation in flowed JSON post-action testseaa3d68bd8Preserve cancellation in flowed package tests1bad8e5df9Preserve cancellation signature in flowed VSTest tests657c04de3bAddress cancellation review feedback85cb62a2f1Fix cancellation shutdown racesValidation
win-x64publish passed.CI is being monitored and failures are being addressed as individual legs report them.
Known validation limitation
The supported Windows
dotnet runinterruption test could not launch because the test application requiresMicrosoft.WindowsDesktop.Apprc.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.