Azure Pipeline VSTest@2 with multiple target frameworks

Viewed 132

I have a project that targets .NET Framework 4.6.1 and also .NET 5.0.

<TargetFrameworks>net461;net5.0</TargetFrameworks>

When I run all tests in the test explorer I can tell see that the number of tests is doubled because they are run for both frameworks however when I run the tests in my Azure Pipeline I can easily tell it's only running one of the target frameworks because the number of tests is cut in half.

How do I tell my Azure Pipeline (YAML) to run my tests against both frameworks?

1 Answers

See documentation for VSTest@2 task:

https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/test/vstest?view=azure-devops

The VsTest task doesn't support running tests that target multiple target frameworks at a time as this is a limitation from the vstest platform side. If you want to run tests that belong to multiple target frameworks, you'll need multiple instances of the vstest task, one per set of dlls that target a particular framework.

Related