After moving MSTest 4 projects to MSTest.Sdk, how do you still get TRX results and code coverage in CI, and what does TestingExtensionsProfile change?
answer
- a referenced extension is not an active one
- --report-trx and --report-trx-filename
- --coverage-output-format cobertura
- Default, AllMicrosoft or None
- Enable<PackageNameWithoutDots> per extension
basics
~20 sMSTest.Sdk's Default TestingExtensionsProfile references the TRX report and code coverage extensions, but each only runs when asked: pass --report-trx for a TRX file and --coverage (with --coverage-output-format cobertura if needed) for coverage. AllMicrosoft adds more extensions; None adds none.
solid answer
~40 sOn Microsoft.Testing.Platform, results and coverage come from **extension packages**, and `TestingExtensionsProfile` decides which ones MSTest.Sdk references: `Default` brings `Microsoft.Testing.Extensions.TrxReport` and `Microsoft.Testing.Extensions.CodeCoverage`; `AllMicrosoft` adds crash and hang dumps, retry, hot reload, HTML report, Fakes and the Azure DevOps and GitHub Actions reporters; `None` brings nothing. Referencing an extension only registers its options. CI must pass `--report-trx` (optionally `--report-trx-filename`) to write a TRX file, and `--coverage` with `--coverage-output-format cobertura` or `xml` to collect coverage in a format a report tool reads. The VSTest switches `--logger trx` and `--collect "Code Coverage"` are not MTP options; MTP rejects them and suggests these replacements. Files land under `TestResults` unless `--results-directory` says otherwise. Individual extensions are toggled with properties such as `EnableMicrosoftTestingExtensionsCodeCoverage`.
code
bash · 5 lines./tests/Billing.Tests/bin/Release/net10.0/Billing.Tests \
--results-directory ./artifacts/test-results \
--report-trx --report-trx-filename billing.trx \
--coverage --coverage-output-format cobertura \
--coverage-output billing.cobertura.xmlgo deeper
Recall that TRX and coverage are extensions on Microsoft.Testing.Platform, switched on per run with --report-trx and --coverage.
Explain the three profiles and the Enable properties, and why a referenced extension produces nothing until its option is passed.
Migrate the pipeline: translate the VSTest switches, pick the coverage format the report step reads, fix the results directory, and account for the test assembly no longer counting toward coverage.
Standardise test reporting across teams: one profile and option set in shared props or testconfig.json, licence review of the extensions used, and one coverage format for the whole portfolio.
## Results and coverage are extensions now Under VSTest, a TRX file came from a **logger** and coverage from a **data collector**, both built into the platform and switched on from the command line or `.runsettings`. Under **Microsoft.Testing.Platform (MTP)**, both are **extensions**: NuGet packages compiled into the test application. - `Microsoft.Testing.Extensions.TrxReport` adds `--report-trx` and `--report-trx-filename`; - `Microsoft.Testing.Extensions.CodeCoverage` adds `--coverage`, `--coverage-output`, `--coverage-output-format` and `--coverage-settings`. The central rule: **a referenced extension is available, not active.** The TRX writer checks whether `--report-trx` was passed and does nothing otherwise. Teams that move to MSTest.Sdk and see no TRX file in CI have usually forgotten the option, not the package. ## What the profile references MSTest.Sdk chooses extension packages through the `TestingExtensionsProfile` property. In the 4.4.1 SDK's targets: | Extension package | `None` | `Default` | `AllMicrosoft` | |---|---|---|---| | `Microsoft.Testing.Extensions.TrxReport` | | yes | yes | | `Microsoft.Testing.Extensions.CodeCoverage` | | yes | yes | | CrashDump, HangDump | | | yes | | Retry, HotReload, HtmlReport, Fakes | | | yes | | AzureDevOpsReport, GitHubActionsReport | | | yes | Any other value fails the build with "Invalid value for property TestingExtensionsProfile". Each package can also be switched individually with a property named `Enable` plus the package id without dots — `EnableMicrosoftTestingExtensionsHangDump` set to `true` adds hang dumps to the `Default` profile, `EnableMicrosoftTestingExtensionsCodeCoverage` set to `false` removes coverage. Some extensions stay opt-in in every profile, such as the JUnit report (`EnableMicrosoftTestingExtensionsJUnitReport`). Licences differ between extensions, which is one reason they are separate packages. ## Asking for the output in CI The reserved scenario is a solution whose MSTest projects move to MSTest.Sdk and MTP in a CI pipeline. The pipeline then needs three changes: 1. **TRX:** pass `--report-trx`, and `--report-trx-filename` when the CI step expects a fixed name. 2. **Coverage:** pass `--coverage`. The default output is a binary `.coverage` file; add `--coverage-output-format cobertura` (or `xml`) for report tools that read Cobertura, and `--coverage-settings` for an XML settings file with include and exclude rules. 3. **Location:** results go to a `TestResults` folder by default; `--results-directory` (or `platformOptions.resultDirectory` in `testconfig.json`) moves them where the publish step looks. The options go to each test application, either when it is run directly or through `dotnet test` in its MTP mode, which forwards them to the test applications. Since MTP 2.3 they can also live in `testconfig.json` under `commandLineOptions`, for example `"report-trx": true`, so every run produces the file without touching the pipeline. ## Choosing the coverage output The coverage extension writes one of three formats, chosen with `--coverage-output-format`: - `coverage` (the default) — a binary file for Visual Studio and the `dotnet-coverage` tool; - `xml` — Microsoft's XML coverage format; - `cobertura` — the format most report generators and CI coverage widgets read. `--coverage-output` sets the file name, and `--coverage-settings` points at an XML settings file that includes or excludes modules, sources and attributes — the place to exclude generated code or to bring the test assembly back if the team wants it counted. ## Old switches and what replaces them - `--logger trx` becomes `--report-trx`. - `--collect "Code Coverage;Format=cobertura"` becomes `--coverage --coverage-output-format cobertura`. - `--blame-hang` becomes `--hangdump` from the HangDump extension. MTP rejects VSTest-only switches with exit code 5 and prints the replacement — and, if the extension is missing, the package that provides it. One more difference shows up in the numbers: the MTP coverage extension excludes the test assembly by default (`IncludeTestAssembly` is `false`), so coverage percentages can shift after the move. ## A source-versus-docs note The current MSTest.Sdk documentation lists the Azure DevOps and GitHub Actions reporters in the `Default` profile from 4.3 onward. The 4.4.1 SDK's own targets enable both only for `AllMicrosoft`; with `Default`, add them with their `Enable…` properties if a pipeline wants them. Either way, those reporters do nothing until their own options (`--report-azdo`, `--report-gh`) are passed.
- Why does a TRX file not appear even though the Default profile includes the TRX extension?The profile only references `Microsoft.Testing.Extensions.TrxReport`, which registers the `--report-trx` option. The extension enables itself only when that option is set, so a run without it writes no TRX. Add `--report-trx` to the CI invocation or to `commandLineOptions` in `testconfig.json`.
- When would you choose the AllMicrosoft profile over Default?When the suite benefits from crash and hang dumps for diagnosing stuck or crashing runs, the retry extension for known-flaky integration tests, or the HTML and CI-specific reporters. It brings more packages, some under more restrictive licences, so many teams stay on `Default` and enable the one or two extensions they need with `Enable…` properties.
- With the Default profile every test run writes a TRX file automatically.
- --logger trx still produces TRX after moving to Microsoft.Testing.Platform.
- The coverage extension writes Cobertura XML unless told otherwise.
- Setting TestingExtensionsProfile to None switches the project back to VSTest.
- Coverage on MTP includes the test assembly, exactly as VSTest did.
- Referencing the HangDump package is enough to capture hang dumps.
Assumes MSTest.Sdk 4.4.1 with Microsoft.Testing.Platform 2.4.1: the Default profile references TRX and coverage, and testconfig.json commandLineOptions needs MTP 2.3 or later.