Skip to content

fix(dotnet): treat global.json MTP as VsTestBridge instead of native mode#1380

Open
danielmarbach wants to merge 1 commit intortk-ai:developfrom
danielmarbach:dotnet-mtp
Open

fix(dotnet): treat global.json MTP as VsTestBridge instead of native mode#1380
danielmarbach wants to merge 1 commit intortk-ai:developfrom
danielmarbach:dotnet-mtp

Conversation

@danielmarbach
Copy link
Copy Markdown
Contributor

@danielmarbach danielmarbach commented Apr 18, 2026

Fixes #1289

Summary

Problem

PR #746 introduced MtpNative mode which injected --report-trx as a direct flag for repos with global.json MTP mode ("test": { "runner": "Microsoft.Testing.Platform" }). This broke xUnit v3 projects with exit code 5:

Unknown option '--report-trx'
Test run completed with non-success exit code: 5

The Altinn/altinn-register repo was affected: .NET 9 SDK, global.json MTP mode, xUnit v3 — no project-file MTP properties at all.

Root cause

--report-trx is not a universal MTP flag. It requires the Microsoft.Testing.Extensions.TrxReport NuGet package which xUnit v3 doesn't bundle (it has --report-xunit-trx instead). MSTest and TUnit bundle it, so it worked for them but failed for xUnit v3.

Verified behavior

All tested with global.json having "test": { "runner": "Microsoft.Testing.Platform" }:

Framework SDK -- --report-trx Direct --report-trx
xUnit v3 3.2.2 .NET 9 ✗ Unknown option ✗ Unknown option
xUnit v3 3.2.2 .NET 10 ✗ Unknown option ✗ Unknown option
MSTest 4.0.2 .NET 9 N/A (MSBuild error)
TUnit 1.36.0 .NET 9 ✓ TRX generated N/A
TUnit 1.36.0 .NET 10 ✓ TRX generated ✓ TRX generated

The xUnit v3 issue reporter confirmed (xunit/xunit#3456) that adding Microsoft.Testing.Extensions.TrxReport NuGet makes --report-trx work universally.

Additionally, -nologo breaks on .NET 10 native MTP with "Unknown option '--nologo'", so it's now skipped for all MTP mode.

Fix

Simplified TestRunnerMode from three variants to two:

  • Classic: VSTest runner → --logger trx --results-directory, -nologo injected
  • MtpVsTestBridge: Any MTP detection (global.json OR project-file) → -- --report-trx, -nologo skipped

Removed MtpNative and MtpGlobalJson. Both global.json MTP and project-file MTP properties now use MtpVsTestBridge, injecting -- --report-trx after the separator.

For xUnit v3 without Microsoft.Testing.Extensions.TrxReport, this produces an informative "Unknown option" error — the user knows to add the package. This is preferable to silently skipping TRX injection, which would regress token savings for the majority of MTP users (MSTest, TUnit) who do bundle TrxReport and benefit from the optimized TRX parsing path. Detecting the NuGet package from csproj/Directory.Build.props/Directory.Packages.props was ruled out as impractical (MSBuild inheritance, central package management).

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test
  • Manual testing: rtk <command> output inspected

Important: All PRs must target the develop branch (not master).
See CONTRIBUTING.md for details.

…mode

PR rtk-ai#746 introduced MtpNative mode which injected --report-trx directly for
global.json MTP, breaking xUnit v3 projects with 'Unknown option' (exit 5).
--report-trx requires Microsoft.Testing.Extensions.TrxReport which xUnit v3
doesn't bundle (it has --report-xunit-trx instead).

Both global.json MTP and project-file MTP now use MtpVsTestBridge, injecting
-- --report-trx after the separator. This works for MSTest/TUnit which bundle
TrxReport. For xUnit v3 without the extension, the error is informative —
tells users to add the NuGet package (per xunit/xunit#3456).

Also skips -nologo for all MTP mode since it breaks on .NET 10 native MTP.

Fixes rtk-ai#1289
@danielmarbach danielmarbach changed the base branch from master to develop April 18, 2026 13:22
@pszymkowiak pszymkowiak added bug Something isn't working effort-medium 1-2 jours, quelques fichiers labels Apr 18, 2026
@pszymkowiak
Copy link
Copy Markdown
Collaborator

[w] wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟡 Risk medium

Summary

Fixes global.json MTP detection to use VsTestBridge mode instead of the removed MtpNative mode, which was injecting --report-trx directly and breaking xUnit v3 projects with 'Unknown option' errors. Also skips -nologo for all MTP modes since it breaks on .NET 10 native MTP, and refactors the project file scanning into a separate function.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #1289


Analyzed automatically by wshm · This is an automated analysis, not a human review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working effort-medium 1-2 jours, quelques fichiers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rtk dotnet test fails on repositories that use the new testing infrastructure

2 participants