.Net Core with multiple projects

  • Community Edition
  • Version 7.9.3 (build 33349)
  • vscoveragexml format
  • Analyze coverage for a .net Core Solution with multiple projects

Hi all,
I apologize if this question is answered or documented elsewhere but I have not been able to find it here or on StackOverflow. Similar, but not the same.

I have a fairly simple .net Core solution containing the following:
*App.Web.csproj (aspnetcore web project)
*App.Data.csproj (class library project)

I am using Visual Studio 2019 Enterprise and the VSTest Console results in the IDE show coverage for all three (including the test project.)

My basic steps (in Jenkins) are as follows (edited for brevity):

dotnet sonarscanner begin <with switches, params etc>

dotnet test --collect “Code Coverage” --results-directory :

CodeCoverage.exe analyze /output:App.coveragexml App.coverage

dotnet sonarscanner end

I am happy to share more detail if necessary.

This is the same setup that we have for another project which is in production and functioning perfectly except that it only has one project plus the test project.

The issue is that the Web project calls the classes in the Data project and the Web project shows coverage but the Data project does not.

Please advise as to what additional information I can provide. I have tried changing formats to opencover but have not been successful thus far. Opencover also presents a different(even less accurate) level of coverage. I have also attempted to implement a runsettings file in the solution to attempt to force the coverage collection but this was also unsuccessful.

I am just trying to confirm that what I am attempting is in fact possible and if so, what am I doing wrong?

Thank you!

Hi all,
I wanted to include an update just in case someone else has this issue. The issue ended up as a difference in the way that dotnet test and the vstest.console collect code coverage.

I basically duplicated the jenkins job and the command stack but replaced the call to dotnet test with a call to the vstest console. Vstest console still produced a .coverage file which needed to be analyzed and converted to a .coveragexml so this was a small change to my job.

So if you find yourself in the same situation, you can can either install vstest console on your jenkins slave or add Microsoft build tools to your project as a nuget package and call vstest.console out of the .nuget folder and the coverage produced from vstest will be accurate.

I was never able to pinpoint the reason for the disparity between the coverage collected by the two tools but I would be interested to know if someone else has.

Hope this saves someone some time!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.