Hi,
code coverage result were working fine on Window(showing result both on Azure devops UI and sonarcloud as well) but not on Linux (only showing on Azure devops UI but not on sonarcloud)
We choose AGent as Ubuntu
Prepare analysis :
sonar.exclusions=/obj/,**/.dll*
sonar.cs.opencover.reportsPaths=$(Build.SourcesDirectory)/coveragereport/.xml*
sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/.trx*
Dotnet test
Argument : –collect:“XPlat Code Coverage”
script :
dotnet tool install -g dotnet-reportgenerator-globaltool
reportgenerator -reports:$(Agent.TempDirectory)//coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/coveragereport -reporttypes:‘HtmlInline_AzurePipelines;Cobertura’*
publish code coverage :
Summary file : $(Build.SourcesDirectory)/coveragereport/Cobertura.xml
report directory : $(Build.SourcesDirectory)/coveragereport
after execution of pipeline shows the result:
dotnet test result -
Starting test execution, please wait…
A total of 1 test files matched the specified pattern.
Results File: /home/vsts/work/_temp/_fv-az162-636_2023-09-06_12_52_05.trx
Attachments:
- /home/vsts/work/_temp/06f71caa-7b01-4820-ab00-49f8caa2c320/coverage.cobertura.xml*
under publish code coverage result:
1. 2023-09-06T12:52:24: Arguments
2023-09-06T12:52:24: -reports:/home/vsts/work/1/s/coveragereport/Cobertura.xml
2023-09-06T12:52:24: -targetdir:/home/vsts/work/_temp/cchtml
2023-09-06T12:52:24: -reporttypes:HtmlInline_AzurePipelines
2023-09-06T12:52:25: Writing report file ‘/home/vsts/work/_temp/cchtml/index.html’
2023-09-06T12:52:25: Report generation took 1.1 seconds
Generated code coverage html report: /home/vsts/work/_temp/cchtml
##[warning]Ignoring coverage report directory with Html content as we are auto-generating Html content
Reading code coverage summary from ‘/home/vsts/work/1/s/coveragereport/Cobertura.xml’
Async Command Start: Publish code coverage
Publishing coverage summary data to TFS server.
Lines- 4116 of 6206 covered.
Branches- 355 of 920 covered.
Modifying Cobertura Index file
Publishing code coverage files to TFS server.
Uploading 176 files
Max dedup parallelism: 192
Building file tree
Uploaded 0 out of 28,946,415 bytes.
Uploaded 28,946,415 out of 28,946,415 bytes.
Associating files
Total files: 176 ---- Associated files: 0 (0%)
File upload succeed.
Published ‘/home/vsts/work/_temp/cchtml’ as artifact ‘Code Coverage Report_2874’
Async Command End: Publish code coverage
Finishing: Publish code coverage from /home/vsts/work/1/s/coveragereport/Cobertura.xml
Under run code analysis shows the result as :
INFO: Parsing the OpenCover report /home/vsts/work/1/s/coveragereport/Cobertura.xml
WARN: Could not import coverage report ‘/home/vsts/work/1/s/coveragereport/Cobertura.xml’ because ‘Missing root element in /home/vsts/work/1/s/coveragereport/Cobertura.xml at line 3’. Troubleshooting guide: [Coverage] Troubleshooting guide for .NET code coverage import
INFO: Sensor C# Tests Coverage Report Import [csharp] (done) | time=64ms
INFO: Sensor C# Unit Test Results Import [csharp]
INFO: Parsing the Visual Studio Test Results file ‘/home/vsts/work/_temp/_fv-az162-636_2023-09-06_12_52_05.trx’.
INFO: Sensor C# Unit Test Results Import [csharp] (done) | time=102ms
still not showing the code coverge result on sonarcloud. so please help me on this issue