Skip to content

[fix] Fix test output eaten by MSBuild terminal logger - #16223

Merged
Jakub Jareš (nohwnd) merged 1 commit into
mainfrom
fix/issue-15509-disable-terminal-logger-for-tests-39f8ccf53a71f46b
Jul 7, 2026
Merged

[fix] Fix test output eaten by MSBuild terminal logger#16223
Jakub Jareš (nohwnd) merged 1 commit into
mainfrom
fix/issue-15509-disable-terminal-logger-for-tests-39f8ccf53a71f46b

Conversation

@nohwnd

Copy link
Copy Markdown
Member

Summary

Fixes #15509

🤖 This is an automated fix.

Root Cause

When TestCaptureOutput=false is set in Directory.Build.props (to allow live test output in the console) and the MSBuild terminal logger is active (default in .NET 8+ SDK), the terminal logger buffers all output from MSBuild sub-tasks — including test output. When tests complete, the terminal logger shows "See log file: (path)" messages. Since TestCaptureOutput=false means no log files are created, those paths point to files that don't exist, leaving developers with no visible test output.

Fix

Disable the MSBuild terminal logger in test.sh and test.cmd by setting MSBUILDTERMINALLOGGER=off before invoking the build scripts. This lets test output flow directly to the console as intended.

Developers who prefer the terminal logger UI can override the default by setting MSBUILDTERMINALLOGGER=auto before invoking the test scripts.

Testing

This is a developer-tooling change affecting only the test.sh and test.cmd scripts. No production code is modified. The change is:

  • test.sh: Exports MSBUILDTERMINALLOGGER=${MSBUILDTERMINALLOGGER:-off} so the default is off but can be overridden.
  • test.cmd: Sets MSBUILDTERMINALLOGGER=off if not already defined.

CI runs (azure-pipelines.yml calls ./test.sh) will also have the terminal logger disabled, which is harmless — CI output is captured by the Azure DevOps agent regardless.

🔍 Triaged by Issue Repro Triage & Auto-Fix 🔍

…ut=false

When TestCaptureOutput=false (set in Directory.Build.props to show test output
live) and the MSBuild terminal logger is active, the terminal logger buffers
all MSBuild subprocess output and shows 'See log file: <path>' messages at the
end. Since TestCaptureOutput=false means no log files are created, these paths
point to files that don't exist, leaving developers with no test output.

Fix: disable the MSBuild terminal logger in test.sh and test.cmd by default via
the MSBUILDTERMINALLOGGER environment variable. Developers who prefer the
terminal logger UI can override this by setting MSBUILDTERMINALLOGGER=auto
before invoking the test scripts.

Fixes #15509

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 7, 2026 01:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses missing/“eaten” test output when running via the repo’s test.sh/test.cmd in environments where TestCaptureOutput=false and the .NET SDK’s MSBuild terminal logger buffers sub-task output. The fix disables the terminal logger by default in the test entry scripts, while still allowing developers to override the setting.

Changes:

  • Default MSBUILDTERMINALLOGGER to off in test.sh to prevent terminal-logger buffering of test output.
  • Default MSBUILDTERMINALLOGGER to off in test.cmd when the variable isn’t already defined (allowing opt-in overrides).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
test.sh Exports MSBUILDTERMINALLOGGER (default off) before invoking the shared build/test entrypoint.
test.cmd Sets MSBUILDTERMINALLOGGER=off (only if unset) before running eng\Build.ps1 -test.

Comment thread test.sh

@nohwnd Jakub Jareš (nohwnd) left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧠 Reviewed by Expert Code Reviewer

Scope

This PR touches only test.cmd and test.sh — thin wrapper scripts that bootstrap scriptroot/DOTNET_ROOT and delegate to the real build engine. No production C# code is modified.

Dimensions activated (per routing table):

  • Build Script & Infrastructure Hygiene — environment variable handling, exit-code propagation, pre-delegate ordering
  • Source Build & Cross-Platform Compliance — bash portability, child-process propagation

Findings

No actionable issues found.

What was checked and passed:

Check Result
if not defined VAR set VAR=off is the correct idiomatic CMD default-value pattern
export VAR=${VAR:-off} is correct POSIX/bash syntax, sets before delegating
Env var is set before the delegated script is invoked (child process inherits it)
exit /b %ErrorLevel% still present in test.cmd — exit-code propagation unaffected
User-override preserved on both platforms (already-set value is not overwritten)
CI pipelines that pre-set MSBUILDTERMINALLOGGER before calling ./test.sh are unaffected

Minor observation (no change needed):

The two scripts have slightly different empty-string semantics:

  • test.sh: ${MSBUILDTERMINALLOGGER:-off} treats an empty value (="") as unset → override to off
  • test.cmd: if not defined treats an empty value as defined → keeps the empty string

If a developer sets MSBUILDTERMINALLOGGER= (empty) to clear the variable, the behavior differs per platform. In practice this is irrelevant — the documented override path is MSBUILDTERMINALLOGGER=auto, not empty-string. No action needed.


PR Description Alignment

The title and description accurately describe the change. The root-cause explanation (TestCaptureOutput=false + terminal logger buffering → missing log-file paths), the fix, and the CI-impact claim all match the diff exactly. ✅

🧠 Reviewed by Expert Code Reviewer 🧠

@nohwnd
Jakub Jareš (nohwnd) merged commit 25d3633 into main Jul 7, 2026
29 checks passed
@nohwnd
Jakub Jareš (nohwnd) deleted the fix/issue-15509-disable-terminal-logger-for-tests-39f8ccf53a71f46b branch July 7, 2026 11:41
This was referenced Sep 9, 2026
This was referenced Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

no results with arcade mtp integration when we don't capture output and -tl:off is not specified?

2 participants