Difference Between `--logger trx` and `--report-trx` for Test Result Generation
Use --logger trx for VSTest (classic) projects and --report-trx for Microsoft.Testing.Platform (MTP) projects; mixing these flags causes unrecognized argument errors.
Understanding the difference between --logger trx and --report-trx is essential when migrating .NET test projects or configuring CI pipelines. These flags belong to two distinct test platforms—VSTest and Microsoft.Testing.Platform (MTP)—and are not interchangeable. This guide references the official dotnet/skills documentation to explain the architectural distinction, required packages, and correct syntax for each platform.
Platform-Specific Command-Line Flags
The primary difference between these flags lies in which test platform interprets them:
--logger trx is processed by VSTest, the classic test runner built into Microsoft.NET.Test.Sdk. It requires no additional packages and emits TRX files through the built-in VSTest logger infrastructure.
--report-trx is processed by Microsoft.Testing.Platform (MTP), the modern extensible test runner. This flag activates the TrxReport extension, which must be explicitly added to your project as a NuGet package.
According to the critical rules table in plugins/dotnet-test/skills/run-tests/SKILL.md (lines 53-55), you must never use --logger trx on MTP projects, as the platform will reject the argument as unrecognized.
VSTest vs Microsoft.Testing.Platform Architecture
The dotnet/skills repository defines specific detection rules to determine which platform is active for a given project.
VSTest detection occurs when a project references Microsoft.NET.Test.Sdk but lacks MTP signals such as "test": { "runner": "Microsoft.Testing.Platform" } in global.json or the <TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport> MSBuild property.
MTP detection requires either:
- SDK 10+:
"test": { "runner": "Microsoft.Testing.Platform" }in global.json - SDK 8/9:
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>in.csprojorDirectory.Build.props
When MTP is detected, the argument parsing pipeline changes entirely. As documented in plugins/dotnet-test-migration/skills/migrate-vstest-to-mtp/SKILL.md (line 203), the flag translation maps -l|--logger trx directly to --report-trx for the new platform.
Required Packages and Extensions
VSTest includes TRX logging capabilities natively. However, MTP follows a minimal-core philosophy where reporting features are opt-in extensions.
To use --report-trx, add the following package reference:
<ItemGroup>
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" Version="1.6.2" />
</ItemGroup>
This requirement is explicitly documented in the migration skill mapping table, which notes that the TrxReport extension handles the actual TRX file generation for the modern platform.
CLI Syntax and SDK Version Differences
Syntax varies depending on your .NET SDK version when using MTP.
SDK 9 and earlier: MTP arguments must be separated from dotnet test arguments using --:
dotnet test MyProject.Tests.csproj -- --report-trx
SDK 10+: The separator is not required; arguments pass directly to the test command:
dotnet test --project MyProject.Tests.csproj --report-trx
This behavior change is documented in the command pattern table in plugins/dotnet-test/skills/run-tests/SKILL.md (lines 66-71).
Practical Examples
VSTest (Classic) Usage
For projects using the traditional VSTest runner:
dotnet test MyProject.Tests.csproj --logger trx
This generates a TRX file in the TestResults/ directory without requiring any additional NuGet packages.
Microsoft.Testing.Platform Usage
For modern MTP projects, first ensure the extension package is referenced, then execute:
# SDK 9 (requires separator)
dotnet test MyProject.Tests.csproj -- --report-trx
# SDK 10+ (no separator needed)
dotnet test --project MyProject.Tests.csproj --report-trx
Incorrect Usage (Platform Mismatch)
Attempting to use VSTest flags on MTP projects results in immediate errors:
# ❌ Fails on MTP projects
dotnet test MyProject.Tests.csproj --logger trx
The MTP runner will report that --logger trx is an unrecognized option. Conversely, using --report-trx on a VSTest project produces a similar error, as the classic runner does not understand the MTP-specific flag.
Summary
--logger trxtargets VSTest (classic) and is built intoMicrosoft.NET.Test.Sdk; no extra packages required.--report-trxtargets Microsoft.Testing.Platform and requires theMicrosoft.Testing.Extensions.TrxReportextension package.- Platform detection rules in
plugins/dotnet-test/skills/run-tests/SKILL.mdprevent mixing these flags; use only the flag appropriate for your detected test platform. - SDK 9 requires the
--separator before MTP arguments, while SDK 10+ passes arguments directly. - Both flags produce standard TRX files compatible with downstream tools like Azure DevOps test result publishers.
Frequently Asked Questions
What happens if I use --logger trx on an MTP project?
The command fails with an unrecognized argument error. According to the critical rules in plugins/dotnet-test/skills/run-tests/SKILL.md (lines 53-55), MTP does not recognize the VSTest logger syntax. You must use --report-trx instead and ensure the Microsoft.Testing.Extensions.TrxReport package is referenced.
Do both flags produce the same TRX file format?
Yes, both generate standard TRX (Test Result XML) files that conform to the Visual Studio Test Results Schema. While the file format is identical, the generating components differ: VSTest uses its built-in logger, while MTP uses the TrxReport extension. Downstream tools like Azure Pipelines or GitHub Actions can consume either file.
Why does my --report-trx command fail on SDK 9?
SDK 9 requires a double-dash separator (--) between dotnet test arguments and MTP-specific arguments. Try:
dotnet test -- --report-trx
In SDK 10+, this separator is no longer required, and you can pass --report-trx directly after dotnet test.
Which package do I need to install for TRX reports in MTP?
You must add the Microsoft.Testing.Extensions.TrxReport package (version 1.6.2 or later) as a PackageReference in your test project. This extension is not included in the base MTP installation, unlike VSTest where TRX logging is built-in.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →