dotnet test only test projects on solution
It is a known issue without a fix. There are some workarounds listed in the issue: https://github.com/Microsoft/vstest/issues/411
Good news, as of right now .NET Core 2.2 has this fixed. Commit: https://github.com/Microsoft/vstest/pull/1745
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:
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>
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.