Xamarin Forms Sonarqube setup - code coverage issue

I am trying to setup the sonarqube code coverage with my xamarin forms project with jenkins in MAC machine but the code coverage still showing 0%

Here is the folder structure for unit test and source code

for unit test
Root /test/Unit/

for source Code
Root /src/mobile/

here is the sonarqube Begin script

source /etc/profile; dotnet-sonarscanner begin /k:"Project" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="token" /d:sonar.verbose=true /d:sonar.cs.opencover.reportsPaths="coverage.opencover.xml" -d:sonar.cs.nunit.reportsPaths="**/unit-test-report.xml,**/unit-test-portable-report.xml" /d:sonar.exclusions="**/*.resx,**/ico,**/*.png,**/*.Designer.cs,**/*.generated.cs" /d:sonar.dotnet.excludeTestProjects=true

to generate unit test report
source /etc/profile; /Library/Frameworks/Mono.framework/Versions/6.12.0/bin/mono /Users/home/NUnit.Console-3.12.0/bin/net35/nunit3-console.exe Tests.dll /result:unit-test-report.xml

to generate coverage report
source /etc/profile; coverlet Tests.dll --target "dotnet" --targetargs "test --configuration Release Unit.Tests.csproj --no-build" --format=opencover --output=coverage.opencover.xml

Sonarque End script
source /etc/profile; dotnet-sonarscanner end /d:sonar.login="token"

In debug log i saw NO INDEXED PATH issue

Note : Number of unit test count is displaying in dashboard but coverage shows 0.0%

Could someone please guide how to fix this issue.


Welcome to the community!

What the docs show is &-ing the OpenCover command onto the build command (which I don’t see in here).

Could you share your full build / analysis log, starting from the begin command?


I did not use OpenCover command instead i used coverlet command

Here is the build and coverage command
msbuild src/mobile/Proj.sln /t:restore /t:clean /p:Platform=iPhone /p:Configuration=Release /t:build

coverlet test/unit/Proj.Unit.Tests/bin/Release/Tests.dll --target "dotnet" --targetargs "test --configuration Release test/unit/Proj.Unit.Tests/Proj.Unit.Tests.csproj --no-build" --format=opencover --output=coverage.opencover.xml

Attached the log link sonar-log.rtf - Google Drive


Hi A.Mohan,

Thanks for the log. In it, you’ve just published an analysis token to the internet. I’m assuming you’ve already revoked it…

I’m a bit out of my depth at this point, so I’m going to ping the experts.


Thanks Ann, any update

Hello and welcome to the community!

Other than coverage, is your project analyzed, do you see issues in the code?

Also, please tell us:

  • what are the commands you are running to do the analysis?
  • are you running all commands from the same folder?

Did you read the Troubleshooting .NET code coverage import?

Thanks Andrei, yes i can see the analysis report. Attached the report for you reference

These are the commands i used to run

source /etc/profile; dotnet-sonarscanner begin /k:“Project” /d:sonar.host.url=“http://localhost:9000” /d:sonar.login=“token” /d:sonar.verbose=true /d:sonar.cs.opencover.reportsPaths=“coverage.opencover.xml” -d:sonar.cs.nunit.reportsPaths=“/unit-test-report.xml,/unit-test-portable-report.xml” /d:sonar.exclusions=“/*.resx,/ico,/*.png,/.Designer.cs,**/.generated.cs” /d:sonar.dotnet.excludeTestProjects=true

source /etc/profile; /Library/Frameworks/Mono.framework/Versions/6.12.0/bin/mono /Users/home/NUnit.Console-3.12.0/bin/net35/nunit3-console.exe Tests.dll /result:unit-test-report.xml

source /etc/profile; coverlet Tests.dll --target “dotnet” --targetargs “test --configuration Release Unit.Tests.csproj --no-build” --format=opencover --output=coverage.opencover.xml

source /etc/profile; dotnet-sonarscanner end /d:sonar.login=“token”

From the root folder i used to run these commands

User path

09:00:47.993 DEBUG: The current user dir is ‘/Users/rm-home/.jenkins/workspace/SonarQube-Job’.

Indexed file paths are relative

09:00:41.490 DEBUG: ‘src/mobile/HidGlobal.ArtemisManager.Portable/ViewModelLocator.cs’ indexed with language ‘cs’

Most files are indexed:

  • 582 files indexed with language ‘cs’
  • 190 files indexed as test with language ‘cs’

Five (5) files are not indexed (Will skip this coverage entry., not clear why), but it’s not that many.

09:00:48.315 DEBUG: The total number of file count statistics is ‘141’.
09:00:48.315 INFO: Coverage Report Statistics: 141 files, 141 main files, 141 main files with coverage, 0 test files, 0 project excluded files, 0 other language files.

So I would expect some coverage to exist.

Could you please share with us

  • the .sonarqube\\out\\sonar-project.properties file
  • the coverage file

I can send a private message if you want.

Could you send us a private message to share the files ?

sure! only you can access this message: https://community.sonarsource.com/t/re-xamarin-forms-sonarqube-setup-code-coverage-issue/68546