How do you run unit tests for a specific target framework in Visual Studio 2017/2019?

I know that the question is about VS, but I find useful that when targeting multiple frameworks dotnet tests command will run tests for all frameworks in <TargetFrameworks> node:

> dotnet test
...
Test run for [projectPath]\bin\Debug\netcoreapp1.1\XUnitTestProject.dll(.NETCoreApp,Version=v1.1)
...
Test run for [projectPath]\bin\Debug\net461\XUnitTestProject.dll(.NETFramework,Version=v4.6.1)
...

NCrunch can also recognize multiple targets and run tests for every target automatically:

enter image description here


Best option currently is to change the order of your target frameworks in the csproj.

<PropertyGroup>
    <TargetFrameworks>netcoreapp2.1;net45;net46;net461;net462;net47</TargetFrameworks>
</PropertyGroup>

If wanting to debug unit tests for net45 framework, you'll need to change it to:

<PropertyGroup>
    <TargetFrameworks>net45;net46;net461;net462;net47;netcoreapp2.1</TargetFrameworks>
</PropertyGroup>

The UI for doing this in Visual Studio would be relatively simple to implement but they have not done so as of this answer.