Repository navigation
Fix TerminalLogger node status restoration after MSBuild task yields - #12820
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an issue where TerminalLogger failed to restore node status after the MSBuild task yields during multi-process builds. The fix ensures that when a node resumes after yielding (when the MSBuild task finishes), the terminal display correctly shows the project's current target and timing information.
Key Changes:
- Added
CurrentTargetproperty to track the currently executing target inTerminalProjectInfo - Implemented
TaskFinishedevent handler to detect when the MSBuild task completes and restore the node status - Added comprehensive unit test with snapshot verification to validate the yield/resume behavior
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| src/Build/Logging/TerminalLogger/TerminalProjectInfo.cs | Added CurrentTarget property to store the name of the currently executing target |
| src/Build/Logging/TerminalLogger/TerminalLogger.cs | Subscribed to TaskFinished event, set CurrentTarget in TargetStarted, and implemented restoration logic in TaskFinished handler |
| src/Build.UnitTests/TerminalLogger_Tests.cs | Added test that simulates MSBuild task yield/resume sequence and verifies node status restoration |
| src/Build.UnitTests/Snapshots/TerminalLogger_Tests.DisplayNodesRestoresStatusAfterMSBuildTaskYields.Windows.verified.txt | Snapshot verification file showing expected terminal output during yield/resume cycle |
baronfel
reviewed
Nov 24, 2025
baronfel
approved these changes
Nov 24, 2025
baronfel
left a comment
Member
There was a problem hiding this comment.
Added some test infra to make multi-node logger testing easier
MichalPavlik
approved these changes
Nov 25, 2025
JanProvaznik
enabled auto-merge (squash)
November 25, 2025 15:50
JanProvaznik
disabled auto-merge
November 25, 2025 16:51
This was referenced Nov 26, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #12819
Context
This PR addresses the root cause of
TerminalNodeStatusbecoming null unexpectedly during builds. This was identified as the underlying cause for issues where test summaries were missing because the logger couldn't attribute events to an active node (discussed in [related PR/Issue]).When the
<MSBuild>task runs, the node yields.TerminalLoggercorrectly cleared the status on yield but failed to restore it upon resume.Changes Made
TaskFinishedhandler inTerminalLogger.cs.MSBuildtask finishes.TerminalNodeStatususing the preservedTerminalProjectInfo(ProjectFile, TargetFramework, etc.) and theCurrentTarget.Testing
DisplayNodesRestoresStatusAfterMSBuildTaskYieldstoTerminalLogger_Tests.cs. This test simulates theTaskStarted("MSBuild")->TaskFinished("MSBuild")sequence and asserts thatDisplayNodes()renders the project status correctly after the task finishes.Notes
This ensures that long-running tasks occurring after an MSBuild task call are correctly visualized in the terminal, and that any logic depending on
_nodes[index]being non-null works as expected.