Hi Ann,
I apologies on that wild card on properties and I have changed it accordingly.
sonar.cs.opencover.reportsPaths=$(Build.SourcesDirectory)/coveragereport/.xml*
sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/.trx*
under dotnet test :
Argument as –collect:“XPlat Code Coverage”
used reportgenerator :
dotnet tool install -g dotnet-reportgenerator-globaltool
reportgenerator -reports:$(Agent.TempDirectory)//coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/coveragereport -reporttypes:‘HtmlInline_AzurePipelines;Cobertura’*
And under publish code coverage :
$(Build.SourcesDirectory)/coveragereport/Cobertura.xml
after executing the pipeline shows the result for each task :
under 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 :
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 result :
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’.
Please go through it and suggest me as still unable to see the code coverage result on sonarcloud