dotnet test only test projects on solution dotnet test only test projects on solution powershell powershell

dotnet test only test projects on solution


If we are talking about dotnet test, this is the relevant issue:

https://github.com/microsoft/vstest/issues/1129

There's a comment that suggests this workaround:

  1. Adding a Directory.Build.targets file in the same directory as the solution, containing:

    <Project>  <Target Name="VSTestIfTestProject">    <CallTarget Targets="VSTest" Condition="'$(IsTestProject)' == 'true'" />  </Target></Project>
  2. Adding a after.[YourSolution].sln.targets file in the same directory as well, replacing [YourSolution] in the name with your actual solution name, containing:

    <Project>  <Target Name="VSTest">    <MSBuild Projects="@(ProjectReference)" Targets="VSTestIfTestProject" />  </Target></Project>

In a later comment he mentioned that he blogged the details of how this works.