-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CustomBuild MSBuild task has trouble cancelling. #9404
Comments
Comment from C++ team: "CustomBuild task is derived from ToolTask (owned by msbuild) which creates the tool process. To be able to cancel a console process, you need to send it console CTRL+BREAK event and for that you need to know its handle, which is private currently. When cpp tasks are using tracker, tracker issues that event on cancellation: But when process is launched without tracking (which is the case in CustomBuild), currently nobody sends the CTRL+BREAK event. So ask to msbuild: either expose tool process handle to derived classes somehow (say, as some protected method) or issue CTRL+BREAK event to the tool process in ToolTask.Cancel(). Note that issuing CTRL+BREAK event and waiting for tool process exit is required to avoid corrupted outputs and problems with subsequent incremental build." |
Fix for #9404 Context We currently do not send the cancelation event to tasks being run by ToolTask, as such, many children task take a long time to cancel, and sometimes they finish executing before said cancelation. This change makes it possible for inherited classes to access the process and check the cancelation event during execution. Changes Made Separated the start of the process to another function that is overridable, as well as exposing the process information. Notes Issue will only be closed once C++ team has incorporated this change into the CustomBuild task.
The full resolution for this ticket depends on the C++ team to implement a solution on their side. If you're looking for further updates please check the original issue at the community feedback page |
Repro Steps:
Expected Result:
The build stops.
Actual Result:
Attempting to cancel the build...
C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(254,5): war
ning MSB4220: Waiting for the currently executing task "CustomBuild" to cancel. [C:\Users\v-evelynyou\TileDB\build\ep_c
atch.vcxproj]
Image
Customer Info:
Link to AzDO feedback work item.
Link to Developer Community feedback item.
[severity:It bothers me. A fix would be nice]
copied from #8999
Issue Description
We have a C++ codebase that uses CMake in a “superbuild” architecture, where an outer CMake project downloads our third-party dependencies, and the inner project contains our own code and is built afterwards.
The problem is that when I build the outer project, I cannot make it immediately stop via Ctrl-C and I have to kill it from the Task Manager. This hinders my development workflow.
Steps to Reproduce
Clone https://github.com/TileDB-Inc/TileDB and open a PowerShell into it.
mkdir build && cd build
Run ../bootstrap.ps1 (should not take long)
Run cmake --build . --config Release and wait a couple of seconds before the next step.
Try to cancel the build with Ctrl-C.
Expected Behavior
The build stops.
Actual Behavior
The build does not stop. Immediately after pressing Ctrl-C I get an Attempting to cancel the build... message.
After some time I getting a C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(248,5): warning MSB4220: Waiting for the currently executing task "CustomBuild" to cancel. [C:\Users\teo\code\TileDB\build\ep_magic.vcxproj]. The build will stop after the currently-building component of the outer project finishes (in this case it was a dependency, but in most cases when the main project gets built, the build is effectively uncancellable).
Analysis
I don’t think this is a problem of CMake because I can cancel the outer build on Unix with Makefiles. It seems that MSBuild struggles to kill the inner build.
Directly building the inner project can be cancelled without any problem.
Versions & Configurations
MSBuild version 17.6.3.22601
CMake version 3.26.0-msvc3
To find diagnostic information, see the original linked feedback ticket.
The text was updated successfully, but these errors were encountered: