3

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?

riQQ
  • 9,878
  • 7
  • 49
  • 66
LorneCash
  • 1,446
  • 2
  • 16
  • 30

1 Answers1

3

See documentation for VSTest@2 task:

https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/vstest-v2?view=azure-pipelines&viewFallbackFrom=azure-devops#does-the-vstest-task-support-running-tests-that-target-multiple-target-frameworks-at-a-time

Yes, starting from version 17.3 VSTest does support running tests that target multiple target frameworks at a time. Prior to that, this wasn't possible due to a limitation from the VSTest platform side.

If you want to run tests that belong to multiple target frameworks, you'll need to install a compatible version of VSTest via Visual Studio Test Platform Installer and set vsTestVersion to toolsInstaller to use it.

aoetalks
  • 1,741
  • 1
  • 13
  • 26
mati
  • 48
  • 7