fix(dotnet): treat global.json MTP as VsTestBridge instead of native mode#1380
Open
danielmarbach wants to merge 1 commit intortk-ai:developfrom
Open
fix(dotnet): treat global.json MTP as VsTestBridge instead of native mode#1380danielmarbach wants to merge 1 commit intortk-ai:developfrom
danielmarbach wants to merge 1 commit intortk-ai:developfrom
Conversation
…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
Collaborator
📊 Automated PR Analysis
SummaryFixes 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
Linked issues: #1289 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
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 #1289
Summary
Problem
PR #746 introduced
MtpNativemode which injected--report-trxas a direct flag for repos withglobal.jsonMTP mode ("test": { "runner": "Microsoft.Testing.Platform" }). This broke xUnit v3 projects with 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-trxis not a universal MTP flag. It requires theMicrosoft.Testing.Extensions.TrxReportNuGet package which xUnit v3 doesn't bundle (it has--report-xunit-trxinstead). MSTest and TUnit bundle it, so it worked for them but failed for xUnit v3.Verified behavior
All tested with
global.jsonhaving"test": { "runner": "Microsoft.Testing.Platform" }:-- --report-trx--report-trxThe xUnit v3 issue reporter confirmed (xunit/xunit#3456) that adding
Microsoft.Testing.Extensions.TrxReportNuGet makes--report-trxwork universally.Additionally,
-nologobreaks on .NET 10 native MTP with "Unknown option '--nologo'", so it's now skipped for all MTP mode.Fix
Simplified
TestRunnerModefrom three variants to two:Classic: VSTest runner →--logger trx --results-directory,-nologoinjectedMtpVsTestBridge: Any MTP detection (global.json OR project-file) →-- --report-trx,-nologoskippedRemoved
MtpNativeandMtpGlobalJson. Both global.json MTP and project-file MTP properties now useMtpVsTestBridge, injecting-- --report-trxafter 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 testrtk <command>output inspected