msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

Rendering message about build cancellation (Terminal Logger)

Open MichalPavlik opened this issue 2 months ago • 8 comments

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: image

Notes

MichalPavlik avatar Apr 22 '24 14:04 MichalPavlik

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?

baronfel avatar Apr 22 '24 14:04 baronfel

I like having "cancelled" logging but it's "failed" because it didn't "complete without errors", which makes sense IMO.

rainersigwald avatar Apr 22 '24 14:04 rainersigwald

@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 :)

MichalPavlik avatar Apr 22 '24 14:04 MichalPavlik

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.

rainersigwald avatar Apr 22 '24 15:04 rainersigwald

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.

MichalPavlik avatar Apr 24 '24 11:04 MichalPavlik

^ @rainersigwald, @ladipro, @rokonec, do you agree?

MichalPavlik avatar Apr 25 '24 07:04 MichalPavlik

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.

ladipro avatar Apr 25 '24 09:04 ladipro

Good tip. It allowed me to discover EngineLoggingServices, which is not in placed in the same directory as the rest logging related types :)

MichalPavlik avatar Apr 25 '24 18:04 MichalPavlik