After a solution's MSTest projects move to MSTest.Sdk, the CI test step on the .NET 10 SDK fails with 'Testing with VSTest target is no longer supported'; why, and how do you fix it?
answer
- UseVSTest false makes an MTP app
- VSTest target refused on SDK 10+
- opt the repository into MTP mode
- translate VSTest switches
- UseVSTest true as a stopgap
basics
~20 sMSTest.Sdk makes each project a Microsoft.Testing.Platform application, which refuses dotnet test's VSTest mode on the .NET 10 SDK. Opt the repository into dotnet test's MTP mode and translate the VSTest switches, or set UseVSTest to true meanwhile.
solid answer
~40 sMSTest.Sdk defaults `UseVSTest` to `false`, so every converted project is an MTP test application (`IsTestingPlatformApplication` is `true`). On a .NET 10 or later SDK the SDK no longer sets `TestingPlatformDotnetTestSupport`, the property that used to let MTP projects ride on `dotnet test`'s VSTest mode, and MTP's MSBuild targets now fail the `VSTest` target with "Testing with VSTest target is no longer supported by Microsoft.Testing.Platform on .NET 10 SDK and later". The fix is to switch the repository's `dotnet test` to its MTP mode — the `test.runner` setting in `global.json` — and then translate the pipeline's switches: `--logger trx` becomes `--report-trx`, `--collect "Code Coverage"` becomes `--coverage`, `--blame-hang` becomes `--hangdump`. If the pipeline cannot change yet, set `<UseVSTest>true</UseVSTest>` for all test projects. Never leave the solution half on each platform.
code
xml · 6 lines<!-- Directory.Build.props: temporary, until CI uses dotnet test's MTP mode -->
<Project>
<PropertyGroup Condition="'$(UsingMSTestSdk)' == 'true'">
<UseVSTest>true</UseVSTest>
</PropertyGroup>
</Project>go deeper
Recall that MSTest.Sdk projects run on Microsoft.Testing.Platform by default, and that CI must either run them as MTP apps or set UseVSTest to true.
Explain why the VSTest target fails for MTP projects on SDK 10+ and what TestingPlatformDotnetTestSupport used to do on older SDKs.
Plan the cut-over: choose MTP mode or a temporary UseVSTest switch for the whole solution, translate every CI switch, check profile extensions and the new exit codes.
Sequence the toolchain change across repositories: SDK upgrade, test SDK conversion and pipeline changes as one coordinated step, with a rollback path through UseVSTest.
## What the error means The reserved scenario: a team converts every MSTest test project in a solution from `Microsoft.NET.Sdk` plus packages to **MSTest.Sdk**, the build passes, and the CI step that ran `dotnet test` now fails with: - "Testing with VSTest target is no longer supported by Microsoft.Testing.Platform on .NET 10 SDK and later. If you use dotnet test, you should opt-in to the new dotnet test experience." Three facts combine to produce it: 1. **MSTest.Sdk defaults `UseVSTest` to `false`.** Each converted project becomes a **Microsoft.Testing.Platform (MTP)** test application: an executable with `IsTestingPlatformApplication` set to `true` and no `Microsoft.NET.Test.Sdk`. 2. **`dotnet test` still starts in VSTest mode** on the .NET 10 SDK unless the repository opts into its MTP mode. In VSTest mode it invokes the MSBuild `VSTest` target for each project. 3. **MTP blocks that path on SDK 10+.** Its MSBuild package hooks the `VSTest` target and raises the error above when the project is an MTP application and the SDK major version is 10 or higher. The old bridge property, `TestingPlatformDotnetTestSupport`, which redirected the `VSTest` target to run MTP executables, is deliberately not set by MSTest.Sdk on SDK 10+. On a .NET 9 SDK the same projects would have run through that bridge; the SDK upgrade and the project conversion together expose the break. ## Fix 1: move the pipeline to MTP 1. **Opt the repository into `dotnet test`'s MTP mode** with the `test` runner entry in `global.json`. It is a repository-wide switch, and it requires every test project to be an MTP application from then on. 2. **Translate the switches** the pipeline passes: | VSTest-era switch | MTP option | Provided by | |---|---|---| | `--logger trx` | `--report-trx` | `Microsoft.Testing.Extensions.TrxReport` | | `--collect "Code Coverage"` | `--coverage` | `Microsoft.Testing.Extensions.CodeCoverage` | | `--blame-hang` | `--hangdump` | `Microsoft.Testing.Extensions.HangDump` | | `--blame-crash` | `--crashdump` | `Microsoft.Testing.Extensions.CrashDump` | | `--settings file.runsettings` | `--settings file.runsettings` | MSTest (partial support) | 3. **Check the extensions.** The `Default` profile references TRX and coverage only; a pipeline that also captures hang dumps needs `EnableMicrosoftTestingExtensionsHangDump` or the `AllMicrosoft` profile, or MTP rejects `--hangdump` with exit code 5. 4. **Re-read the exit codes.** A project or filter that runs no tests now fails with exit code 8, which can surface test projects that were silently empty. ## Fix 2: stay on VSTest for now Setting `<UseVSTest>true</UseVSTest>` — ideally once, in a `Directory.Build.props` that every test project imports — makes MSTest.Sdk import its VSTest branch. That branch references `Microsoft.NET.Test.Sdk` and the adapter, so `dotnet test` in VSTest mode and `vstest.console` work exactly as before, and the team keeps the shorter project files while scheduling the pipeline work. One catch: the VSTest branch rejects MTP-only properties, so a project that sets `TestingExtensionsProfile` or any `EnableMicrosoftTestingExtensions…` property fails the build with "'TestingExtensionsProfile' is not supported by VSTest." — remove those for the transition. ## What not to do - **Do not mix platforms.** A solution where some test projects are MTP applications and others are VSTest libraries is unsupported in either `dotnet test` mode: switches meant for one platform are misread by the other. - **Do not expect a hand-added `Microsoft.NET.Test.Sdk` to clear the error.** The MSTest 4 migration guide mentions that package for running MTP projects with `vstest.console` itself, but the projects stay MTP applications, so `dotnet test`'s VSTest mode still hits the blocked target. Choose a platform with `UseVSTest`. - **Do not pin the CI agent to an older SDK** as the fix; it postpones the same break and loses .NET 10's MTP mode. ## Rolling it out across the solution - Convert **all** test projects in one change, so no commit leaves the solution split between platforms. - Put shared choices — the extensions profile once on MTP, or `UseVSTest` during a transition (never both), and parallelism — in one `Directory.Build.props` instead of each project file. - Pin the MSTest.Sdk version once in `global.json` under `msbuild-sdks`, so local machines and CI agents resolve the same SDK. - Change the pipeline in the same pull request as the projects, and keep the `UseVSTest` switch ready as the rollback. ## Verifying the move After the switch, run one project's test executable directly with the CI's options. If it writes the TRX and coverage files where the publish step expects them and exits 0, the pipeline change is complete.
- Why does the same conversion work on a .NET 9 SDK but fail on .NET 10?On SDK 9 and earlier, MSTest.Sdk sets `TestingPlatformDotnetTestSupport` to `true`, so the `VSTest` target is redirected to run the MTP executables. On SDK 10 and later it leaves that property unset, expecting the repository to use `dotnet test`'s MTP mode, and MTP's targets fail the `VSTest` target outright for MTP projects.
- Is adding Microsoft.NET.Test.Sdk to the projects a valid fix for the error?No. The projects remain MTP applications because `UseVSTest` is still `false`, so the `VSTest` target still fails; the package only helps when `vstest.console` itself runs the project. The supported ways out are opting the repository into MTP mode, or setting `UseVSTest` to `true`, which makes MSTest.Sdk add that package itself.
- The error means MSTest.Sdk does not support the .NET 10 SDK.
- Adding Microsoft.NET.Test.Sdk by hand fixes the VSTest target error.
- --logger trx keeps working unchanged once the projects use MTP.
- Converting only some test projects to MSTest.Sdk is a safe intermediate state.
- With UseVSTest true, TestingExtensionsProfile still adds the TRX and coverage extensions.
- Pinning CI to the .NET 9 SDK is the recommended long-term fix.
Assumes MSTest.Sdk 4.4.1 and Microsoft.Testing.Platform 2.4.1 on the .NET 10 SDK, where MTP blocks the VSTest target and MSTest.Sdk no longer sets TestingPlatformDotnetTestSupport.