When you create coverage reports for your .NET projects you have the ability to use the native logger mechanism in order to export a trx report with your results.
An example of this native functionality can be found below as the logger parameter is used along with dotnet test.
dotnet test keyvault.sln --logger "trx;logfilename=mytests.trx"
However if you try to upload this trx file in a sonarqube in order to get your coverage report result, this will fail with the below error message.
WARN: Could not import coverage report ‘.\Keyvault_MI_Pod\Tests\TestProject1\TestResults\mytests.trx’ because ‘Only dotCover HTML reports which start with “” are supported.’. Troubleshooting guide: https://community.sonarsource.com/t/37151
Using the below sonarqube documentation page you will find all the available methods that are supported for the coverage reporting. When you need to upload your coverage results in sonarqube you will need to use a tool from the list and upload the file that this tool generates.
In my case I will use dotCover and create the relevant report file.
In the teamcity task (begin analysis) you will need to add in the additional parameters where you export your report.
Then in the pipeline you will need to add the dotnet test task as shown from the documentation.
dotnet dotcover test --dcReportType-HTML
In the finish task you will see the coverage report type is now compatible and can be parsed from sonarqube.
Finally you will have your coverage report inside sonarqube.