Skip to content

ctrl+c is not respected when --framework is passed to 'dotnet build' #11680

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

Open
RikkiGibson opened this issue Apr 3, 2025 · 4 comments · May be fixed by #11869
Open

ctrl+c is not respected when --framework is passed to 'dotnet build' #11680

RikkiGibson opened this issue Apr 3, 2025 · 4 comments · May be fixed by #11869
Assignees
Labels
Area: Terminal Logger Problems with the livelogger/fancylogger/terminallogger -tl functionality. Priority:1 Work that is critical for the release, but we could probably ship without triaged

Comments

@RikkiGibson
Copy link
Member

Issue Description

ctrl+c normally cancels the build, but it doesn't do that when --framework <target-framework> is passed to the CLI. You have to just sit there until the build finishes.

Steps to Reproduce

  • Get yourself a chunky project, like, I dunno, one of the projects in this repo, or dotnet/sdk repo, or dotnet/roslyn.
  • Run a command similar to one of the following examples
    • dotnet build ./test/dotnet.Tests/ --framework net10.0 in dotnet/sdk
    • dotnet build ./src/Compilers/CSharp/Portable --framework net9.0 -t:rebuild in dotnet/roslyn.
  • Wait for the restore step to finish and the actual build to begin. Also, I think this won't repro if everything is up to date and rebuild is not specified, difficult to be certain though.
  • Hit ctrl+c while the build is underway.

Expected Behavior

Build is cancelled.

Actual Behavior

Build does not cancel, you either have to terminate the terminal process and its children, or sit there and wait.

Analysis

No response

Versions & Configurations

In Roslyn I am using dotnet 9.0.104
In SDK I am using dotnet 10.0.100-preview.3.25125.5

@RikkiGibson
Copy link
Member Author

RikkiGibson commented Apr 3, 2025

Note that this behavior can occur using both ordinary dotnet build as well as similar dotnet test commands which implicitly run the build.

@baronfel
Copy link
Member

baronfel commented Apr 3, 2025

@RikkiGibson I am just bad at reading and didn't realize this was against the MSBuild repo - I've deleted my tag as a result!

@baronfel
Copy link
Member

baronfel commented Apr 4, 2025

Other notes:

  • this happens only in TL, not console logger.
  • the abort message isn't written at all - this suggests that the BuildCanceledEventArgs fired by LogBuildCanceled (which is called by CancelAllSubmissions) isn't being fired or processed? The abort message is written, it's just swallowed by the other in-progress builds continuing to write.

@YuliiaKovalova YuliiaKovalova added the Area: Terminal Logger Problems with the livelogger/fancylogger/terminallogger -tl functionality. label Apr 8, 2025
@maridematte maridematte added Priority:1 Work that is critical for the release, but we could probably ship without triaged labels Apr 8, 2025
@YuliiaKovalova YuliiaKovalova self-assigned this Apr 23, 2025
@JaynieBai
Copy link
Member

JaynieBai commented May 16, 2025

This also reproes when /tl:off, the issue is related with --framework. @rainersigwald should we fix this issue in the dotnet. since the args are from dotnet.

When --framework, the msbuild args are with /target:Restore. so, it will restore only at first

bool restoreOnly = targets.Length == 1 && string.Equals(targets[0], MSBuildConstants.RestoreTargetName, StringComparison.OrdinalIgnoreCase);
, after restore successfully, it will set static property s_buildComplete. When build and ctrl+c, the s_buildComplete has been set and s_cancelComplete.Set();

msbuild/src/MSBuild/XMake.cs

Lines 1188 to 1193 in f5b4822

// If the build is already complete, just exit.
if (s_buildComplete.WaitOne(0))
{
s_cancelComplete.Set();
return;
}

Generate the binlog folders with --framework and without --framework
NoFramework.zip

withFramework.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Terminal Logger Problems with the livelogger/fancylogger/terminallogger -tl functionality. Priority:1 Work that is critical for the release, but we could probably ship without triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants