Skip to content

Emit Azure DevOps logging commands at column 0 from the MSBuild test runner - #9895

Merged
Amaury Levé (Evangelink) merged 2 commits into
mainfrom
dev/amauryleve/fix-azdo-test-grouping
Jul 13, 2026
Merged

Amaury Levé (Evangelink) merged 2 commits into
mainfrom
dev/amauryleve/fix-azdo-test-grouping

Conversation

@Evangelink

Copy link
Copy Markdown
Member

What

Fixes the broken Azure DevOps log-grouping feature when running tests through the MSBuild runner (dotnet test / dotnet build -t:Test with TestingPlatformCaptureOutput=false).

Symptoms reported (see e.g. this build):

  1. Log group expand/collapse doesn't work.
  2. Garbled markers such as oup]Tests: Microsoft.Testing.Extensions.VSTestBridge.UnitTests (net8.0).

Root cause

Both symptoms are the same bug — the ##[group] command lines are indented, so the Azure Pipelines agent stops recognizing them.

  1. Each test host (single assembly) correctly writes ##[group]Tests: … at column 0 to its own stdout (via Microsoft.Testing.Extensions.AzureDevOpsReport).
  2. InvokeTestingPlatformTask (a ToolTask) captures that stdout and re-emits every line through Log.LogMessage(High, …) in LogEventsFromTextOutput.
  3. MSBuild's console logger indents task messages by 2 spaces, so the raw pipeline log shows ##[group]Tests: ….
  4. Azure Pipelines only honors logging commands (##[group], ##[endgroup], ##vso[...]) when they start at column 0 (no trimming). Indented ⇒ no collapse, and the AzDO web UI renders the unrecognized marker as garbled text.

Fix

In InvokeTestingPlatformTask.LogEventsFromTextOutput, route Azure DevOps command lines (starting with ##[ or ##vso[) straight to Console.Out (column 0) instead of the indenting Log.LogMessage. All other output keeps flowing through MSBuild logging unchanged.

Each assembly's ##[group] (session start) and ##[endgroup] (session end) run through the same task instance on the same node, so markers stay matched.

Tests

  • IsAzureDevOpsLoggingCommand classifier data rows (commands vs. regular/indented output).
  • A routing test asserting AzDO command lines are written to stdout verbatim at column 0 and are not routed through the (indenting) MSBuild logger, while regular output still goes through the logger.

All 20 unit tests in Microsoft.Testing.Platform.MSBuild.UnitTests pass; build is warning-free.

Known limitation (follow-up)

Under multi-node dotnet test (-m), a task's Console.Out is only delivered from the in-proc node — worker-node console output is dropped by MSBuild. So after this change:

  • Garbling is eliminated everywhere.
  • Grouping collapses correctly for in-proc-node assemblies and for single-project / direct-terminal runs.
  • Worker-node assemblies lose the markers (no garbling); their output is interleaved across assemblies anyway, which independently breaks grouping semantics.

Making grouping fully correct under parallel, interleaved dotnet test needs per-assembly output serialization/buffering; I'll follow up with an exploration/issue.

The AzureDevOpsReport extension writes ##[group]/##[endgroup]/##vso[...]
commands at column 0 on the test host stdout. The MSBuild InvokeTestingPlatformTask
captured that stdout and re-emitted it via Log.LogMessage, which the MSBuild
console logger indents by 2 spaces. Azure Pipelines only honors logging commands
that start at column 0, so the log groups stopped collapsing and the markers
rendered as garbled text (e.g. 'oup]Tests:').

Route Azure DevOps command lines straight to Console.Out (column 0) instead of
through the indenting MSBuild logger; all other output is unchanged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e7a0af3b-eb61-4740-8da4-9890d0468cc9
Copilot AI review requested due to automatic review settings July 13, 2026 10:44

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

Routes Azure DevOps logging commands directly to stdout so MSBuild does not indent and invalidate them.

Changes:

  • Detects Azure DevOps command lines and preserves column-zero output.
  • Adds classifier and routing unit tests.
Show a summary per file
File Description
InvokeTestingPlatformTask.Execution.cs Routes Azure DevOps commands directly to stdout.
InvokeTestingPlatformTaskTests.cs Tests command classification and output routing.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Medium

The routing test replaces process-wide Console.Out; this project runs
method-level parallel tests, so isolate it to avoid capturing another
test's output or racing on Console.Out restoration.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e7a0af3b-eb61-4740-8da4-9890d0468cc9
Copilot AI review requested due to automatic review settings July 13, 2026 11:06

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.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Low

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test quality grade — PR #9895

GradeTestNotes
B (80–89) mod InvokeTestingPlatformTaskTests.
LogEventsFromTextOutput_
AzureDevOpsCommands_
AreWrittenToStdoutAtColumnZero_
NotThroughMSBuildLog
Rich positive + negative assertions verify AzDO routing and normal-output behavior; body is ~45 lines due to necessary try/finally Console.Out scaffolding — consider extracting the capture pattern into a helper to improve readability.

This advisory comment was generated automatically. Grades are heuristic and informational — they do not block merging. Re-run with /grade-tests.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

🤖 Automated content by GitHub Copilot. Generated by the Grade Tests on PR (on open / sync) workflow. · 37.4 AIC · ⌖ 8.49 AIC · ⊞ 8.9K · [◷]( · ◷)

@Evangelink
Amaury Levé (Evangelink) enabled auto-merge (squash) July 13, 2026 12:27
@Evangelink Amaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Jul 13, 2026
@Evangelink
Amaury Levé (Evangelink) merged commit 7acaf58 into main Jul 13, 2026
40 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/fix-azdo-test-grouping branch July 13, 2026 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-review Awaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants