Why does SonarCloud plugin refuses to scan my code base!

Folks,

I have spent hours and hours on this. I have no success so far…

In my solution is on Azure DevOps and and I am trying to do analysis using SonarCloud (SC) plugin. My project solution has the following structure:

All source code, and code folders at root level.
All Azure related yml and scripts in .azuredevops folder.

Here is my yml setup for SonarCloud

- task: SonarCloudPrepare@1
  inputs:
    SonarCloud: 'SonarCloud Service Principal for HeathDataRepository repository'
    organization: 'heathpbu'
    scannerMode: 'MSBuild'
    projectKey: 'heathpbu_HeathDataRepository'
    projectName: 'HeathDataRepository'
    extraProperties: |
      # Additional properties that will be passed to the scanner, 
      # Put one key=value per line, example:
      sonar.sources='($Build.SourcesDirectory)'
      sonar.visualstudio.solution='**/*.sln'
      sonar.visualstudio.enable=true
      sonar.cs.opencover.reportsPaths='$(Agent.TempDirectory)\coverage.opencover.xml'

# This task analysis the source code
- task: SonarCloudAnalyze@1

# Publish the SonarCloud analysis results
- task: SonarCloudPublish@1
  inputs:
    pollingTimeoutSec: '300'

My pipeline runs fine…

From the logs:

  1. Analyzed finds my project
    2022-09-08T11:40:38.7527022Z INFO: Found 1 MSBuild C# project: 1 MAIN project.

  2. It also seem to index these files

2022-09-08T11:40:13.7895398Z INFO: 611 files indexed
2022-09-08T11:40:13.7987701Z INFO: 0 files ignored because of inclusion/exclusion patterns
2022-09-08T11:40:13.7991335Z INFO: 0 files ignored because of scm ignore settings
  1. It seems it is analyzing the files too
2022-09-08T11:40:21.2522271Z INFO: 609 source files to be analyzed
2022-09-08T11:40:21.2523881Z INFO: 609/609 source files have been analyzed

However there is only 23 lines in the report. Can someone guide me on what am I missing?

SCLogs.txt (22.1 KB)

@HeathUS,

You don’t need to set any of the following properties when using the extension in MSBuild mode (and the last two have been obsolete since at least 2016):

Can you share verbose logs for the analyse step please? (pass “sonar.verbose=true” as an extra property in the prepare step)

Thank you for reaching out Duncan… I now have revised the section to the below, and enclosed the verbose logs.

I am not sure if it matters, but my azurepipelines.yml is not in the root folder but under .azuredevops folder so I can keep all the devops scripts under one folder and protect them.

All I see is SC does not see beyond this yml file.

- task: SonarCloudPrepare@1
  inputs:
    SonarCloud: 'SonarCloud Service Principal for HeathDataRepository repository'
    organization: 'heathpbu'
    scannerMode: 'MSBuild'
    projectKey: 'heathpbu_HeathDataRepository'
    projectName: 'HeathDataRepository'
    extraProperties: |
      # Additional properties that will be passed to the scanner, 
      # Put one key=value per line, example:
      sonar.verbose=true
      sonar.cs.opencover.reportsPaths='$(Agent.TempDirectory)'/coverage.opencover.xml

SCLogs.txt (5.5 MB)

Hi @HeathUS. Apologies for the delay in replying.

No, it doesn’t matter.

Your original screenshot appears to be for a pull request from a feature branch to master, so it’s saying there are no new issues in the PR. Do you have issues reported against the master branch itself?

The second log you uploaded contains information about 271 issues in about 100 files (search for e.g. Adding normal issue S125 to see this issues in the log).

Also, it looks like the coverage file is not being found. I think you need to change what you are passing in the yaml from

 sonar.cs.opencover.reportsPaths='$(Agent.TempDirectory)'/coverage.opencover.xml
 sonar.cs.opencover.reportsPaths='$(Agent.TempDirectory)/coverage.opencover.xml'

Hi Duncan,

I made the changes you suggested with no impact on SonarCloud. It still does nor publish report properly.

Thanks
Muthu