dotCover CLI Microsoft.Testing.Platform support

Hello,

I was wondering if there is any good documentation on how to use the dotCover CLI with Microsoft.Testing.Platform projects?

After installing “dotnet tool install --global JetBrains.dotCover.CommandLineTools --version 2025.3.1” I tried to run “dotCover cover --target-arguments "test --no-build --solution D:\Repos\MTP\MTP.sln" ”, but got the following error message:

“MSBUILD : error MSB1001: Unknown switch.
   Full command line: 'C:\Program Files\dotnet\sdk\10.0.101\MSBuild.dll -maxcpucount --verbosity:m -tlp:default=auto --property:VsTestUseMSBuildOutput=true --property:VSTestNoBuild=true --property:NuGetInteractive=true --property:VSTestArtifactsProcessingMode=collect --property:VSTestSessionCorrelationId=4612_b5282a8d-ddd6-4e23-817f-354305b6c6b9 --target:VSTest -nologo --solution D:\Repos\ETC\ThreeShape.DesignSystem.Styles\ThreeShape.DesignSystem.Styles.sln -distributedlogger:Microsoft.DotNet.Cli.Commands.MSBuild.MSBuildLogger,C:\Program Files\dotnet\sdk\10.0.101\dotnet.dll*Microsoft.DotNet.Cli.Commands.MSBuild.MSBuildForwardingLogger,C:\Program Files\dotnet\sdk\10.0.101\dotnet.dll'
 Switches appended by response files:
Switch: --solution”

When I run without the --solution switch I get the following error:

“Testing with VSTest target is no longer supported by Microsoft.Testing.Platform on .NET 10 SDK and later. If you use dotnet test, you should opt-in to the new dotnet test experience. For more information, see https://aka.ms/dotnet-test-mtp-error”

From the logs it looks like dotCover tries to run the tests with VSTest that does not support MTP. I saw that for the Raider there is a checkbox to set the dotCover for Microsoft.Testing.Platform, but I could not find if there is the same option for the CLI.

When I execute “dotnet test --solution . ” the tests run successfully, so there is no issue on that side.

An additional issue with the dotCover is that it is not looking for the sln/csproj/dll files from the root of where the command was executed and you need to pass the full path, which is inconvenient.

0
1 comment

Hello, 

Sorry for the late response due to the holiday season. 

Regarding this issue, why “--solution” is not recognized correctly is because this switch is only visible in MTP mode. You're probably running the tests under VSTest mode. Please follow Microsoft.Testing.Platform (MTP) mode of dotnet test to add global.json file and enable MTP mode. 

Besides, the default working directory of “dotCover” command is folder of “dotnet”, thus global.json file in your project root will not be recognized. To resolve this, please specify working directory using “--target-working-directory” argument. 

The below is a working sample on my end:
dotCover cover --target-working-directory . --target-arguments "test --no-build --solution /Users/tomluo/RiderProjects/XUNITV3App1/XUNITV3App1.slnx"

Another thing is that once “--target-working-directory” is used, you don't have to pass the full path of sln/csproj/dll files. 

Please also note, there is a known issue that TUNIT with MTP is currently not supported yet: DCVR-12871 Not receiving coverage from TUnit (Testing Platform) tests in dotCover 

If the issue persists, please upload a sample project that can reproduce the issue to our upload service and share the upload ID.

Thanks,

Tom

 

 

 

 

0

Please sign in to leave a comment.