Testing with VSTest target is no longer supported in .NET 10 and Azure DevOps
I recently updated a few NuGet packages - including moving from the deprecated xunit package to xunit.v3 - (or updating xunit.v3 to the latest version). I ran the tests locally and everything was green so I pushed my changes. In Azure DevOps however the DotNetCoreCLI@2 test step failed with:
error : 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. For more information, see https://aka.ms/dotnet-test-mtp-error
It also included usual warnings about .NET Core 2.2/3.0 being EOL and .NET 5 NuGet compatibility. But we can ignore those.
My AI friend came to the rescue and I was able to get my tests running again - this is a recap of why it broke only on the build server, and how to fix it.
What changed for testing
Your test run on Azure DevOps was using dotnet test and VSTest: the project compiles, VSTest spins up a test host process and a framework adapter (like xunit.runner.visualstudio) discovers and runs the tests. Microsoft is replacing VSTest with Microsoft.Testing.Platform (MTP), where the test project compiles into a standalone executable that hosts its own runner.
When I moved from the deprecated xunit package onto xunit.v3 (specifically the 4.x version), that pulled in MTP v2 by default. That is important because in the .net10 sdk dotnet test is split into the legacy VSTest mode (still the default) and a new native MTP mode. And even more significant is that MTP v2 no longer VSTest has a bridge as from .NET 10. So in v1 you could run an MTP test project through VSTest-mode but in v2 and .NET 10 you have to run dotnet test in native MTP mode.
It works locally because in Visual Studio MTP is used directly and we don't need VSTest mode. The Azure Pipeline DotNetCoreCLI@2 task however defaulted to VSTest mode.
The fix
You have two options: move to the new MTP mode (recommended), or tell xUnit to turn MTP off (don't).
Option 1: Switch to Microsoft.Testing.Platform
1. Add a global.json at the root of your repository
{
"test": {
"runner": "Microsoft.Testing.Platform"
}
}
Put this global.json at the git repository root (so not in a subfolder next to your solution file). By default Azure DevOps runs from the repository root and looks for global.json there.
(If you also use a UseDotNet@2 task with useGlobalJson: true, make sure you keep your "sdk" section in the same global.json.)
2. Add the TRX report extension package
Once DotNetCoreCLI@2 sees MTP enabled in global.json, its built-in test result publishing stops passing --logger trx and starts passing --report-trx instead. In xUnit v3, TRX reporting is not built into the core package so you need a separate extension package. Without it, the test run will fail because the parameter --report-trx isn't recognized. To fix this you have to add a package reference for Microsoft.Testing.Extensions.TrxReport to your test project.
3. Check the flags in your deploy step
Normally your test step will work without changes after those two steps. But just double-check the arguments in your build step definition to make sure you aren't manually passing VSTest-only switches or expressions (see the dotnet test MTP docs for the updated flags).
Option 2: Stay on VSTest for now
If you really need to (which you shouldn't) , xUnit publishes separate package variants that explicitly disable MTP like xunit.v3.mtp-off , o you can use those in your test project (alongside xunit.runner.visualstudio and Microsoft.NET.Test.Sdk), and dotnet test will keep using VSTest on .NET 10 just like before.