msbuild
msbuild copied to clipboard
Rendering message about build cancellation (Terminal Logger)
Fixes #8983
Context
When you cancel command-line MSBuild, we send the cancellation signal through the API and also writes status to stdout. But it does it directly in XMake, and TL tends to immediately overwrite that message with status updates, so it's not obvious whether cancellation is in progress.
Changes Made
TL now has instance of cancellation token and writes message on it's own. TODO: Do similar change in Console Logger and remove write from XMake, otherwise TL can display the message twice in some scenarios.
Testing
Manual:
Notes
Follow-on question - it's always kind of bothered me that a cancelled build is considered failed
for purposes of coloration/reporting. Do we know the reason why the build failed? Could we special-case the final build summary to say something like Build [red]cancelled[/red] after {elapsed_time}
in that case to be more precise?
I like having "cancelled" logging but it's "failed" because it didn't "complete without errors", which makes sense IMO.
@rainersigwald, you mentioned that you would like to have the "build cancellation event". Could you please elaborate? Would it be just a new event or it will be used also as an indication for loggers to stop (instead of cancellation token)? Token is still IMO expected way how to cancel :)
I was thinking more or less of a new BuildCancelledEventArgs
that the engine would raise to indicate to loggers to emit a message like this one. That could then be logged in with precise timing in the binlog too, which may be helpful for some analyses.
It seems there is no infrastructure for emitting events where the context is overall build (or I didn't looked properly). If no one knows how/where to send the event without node/project/target/task context, then I propose to finish this issue with cancellation token and create new issue tracking the "global events" API.
^ @rainersigwald, @ladipro, @rokonec, do you agree?
I would expect the new event to use something analogous to BuildFinishedEventArgs
, which is also raised without project context. Hope I'm not misunderstanding or missing anything obvious.
Good tip. It allowed me to discover EngineLoggingServices
, which is not in placed in the same directory as the rest logging related types :)