Scan results not showing on project summary (despite showing in dashboard)

Hi!

We have a number of projects that are being scanned by SonarCloud but are seeing the issue described in the title for one project and I’m hoping to get some help finding a fix. To summarize:

On the ‘Projects’ list, this project does not display the main branch scan summary that shows for our other projects:

When we click into the project, the overview shows a successful scan result:

The analysis also seems to be producing results for the main branch:

Can anyone help us determine why we’re not seeing results for the main branch in the project summary? Thanks!

-Shane

  • ALM/CI used: Azure DevOps
  • Scanner command used (on main branch build):
- task: SonarCloudPrepare@1
displayName: 'Prepare SonarCloud Analysis'
inputs:
  SonarCloud: 'SonarCloud'
  organization: '<sonar org>'
  scannerMode: 'MSBuild'
  projectKey: '<sonar key>'
  projectName: '<proj name>'
  extraProperties: |
    sonar.verbose=true
    sonar.modules=services
    services.sonar.projectName=<proj name>
    services.sonar.projectBaseDir=$(Build.SourcesDirectory)/$(CheckoutFolder)/Src
    services.sonar.sources=$(Build.SourcesDirectory)/$(CheckoutFolder)/Src/<proj>/Services/<proj>.Services,$(Build.SourcesDirectory)/$(CheckoutFolder)/Src/<proj>Common/<proj>.Infrastructure,$(Build.SourcesDirectory)/$(CheckoutFolder)/Src/<proj>Business/BusinessLogic/<proj>.Domain
    services.sonar.tests=$(Build.SourcesDirectory)/$(CheckoutFolder)/Src/UnitTests/<proj>Business/BusinessLogic/<proj>.Domain.Tests
    sonar.branch.name=$(Build.SourceBranchName)
    sonar.cs.vstest.reportsPaths=$(Net6TestResults)/**/*.trx
    sonar.cs.opencover.reportsPaths=$(Agent.TempDirectory)/**/*.opencover.xml
    sonar.exclusions=**/bin/**,**/obj/**,$(Build.SourcesDirectory)/$(CheckoutFolder)/Src/<proj>Business/BusinessLogic/<proj>.Models/**,**/Models/**
    sonar.cs.analyzeGeneratedCode=true
    sonar.cs.ignoreHeaderComments=true
  • C#/dotNet

I’ve reached out to you by private message for organization/project details.

@shanemw

Could you please share the detailed build logs?

MsBuild.exe /t:Rebuild /v:d

or

dotnet build -v:d

All the best,
Čaba

Hi Čaba,

Would it be possible to schedule some time for a screen sharing session to have a look? We’re building using an Azure DevOps task on an auto-provisioned agent but I believe the logs I attached earlier should include the verbose output from msbuild. Thanks!

-Shane

@shanemw

I am sorry to inform you that we cannot have a screen-sharing session.

I double-checked the logs that you have sent and they don’t contain the verbose-level build logs.
You have provided the logs of the Prepare Analysis Configuration and the Run Code Analysis steps.
As I mentioned above what we need to continue with the investigation is the detailed build logs.

Hi Čaba,

Attached you’ll find the build logs. Let me know what you can find. Thanks,

-Shane

faBuild.txt (1.13 MB)

@shanemw

I cannot see any mention of sonar in the logs, which is weird.
Could you please share the commands you are running in your build pipeline with us?

Best,
Čaba

Hi Čaba,

I think there’s a disconnect here. We’re building and scanning from Azure DevOps pipelines so it wouldn’t really make sense to see sonar logs on the build. We’re building using the ‘VsBuild@1’ Azure DevOps task (which essentially just runs msbuild.exe) and targeting our solution file. The sonar prepare/scan tasks are run separately within the pipeline (prepare is run before the build, scan is run after). Thanks,

-Shane

@shanemw

The prepare task injects our C# analyzers into the build. And the analyzers are executed as part of the build of your project. This means I should see in the verbose level logs of the build that our analyzers are injected, and yet I don’t see this. This is why I was interested in where and how you exactly invoke each task.

I see, thanks for the clarification. Any ideas why the sonar prepare task might not be injecting the analyzers appropriately?

I cannot tell yet, that is why I was asking you if you could provide me with the script that calls the tasks.

All the best,
Čaba

Hi Čaba,

We are using Azure DevOps so the scripts are invoked through powershell runner tasks (documentation found here) using the parameters in our pipeline yaml files found below. Let me know if anything jumps out from this, or if you need additional information

  • task: SonarCloudPrepare@1
    displayName: ‘Prepare SonarCloud Analysis’
    inputs:
    SonarCloud: ‘SonarCloud’
    organization: ‘kaufmanhallprod’
    scannerMode: ‘MSBuild’
    projectKey: ‘KaufmanHallProd_FAPortal’
    projectName: ‘FAPortal’
    extraProperties: |
    sonar.verbose=true
    sonar.modules=services
    services.sonar.projectName=FAPortal
    services.sonar.projectBaseDir=$(Build.SourcesDirectory)/$(FACheckoutFolder)/Src
    services.sonar.sources=$(Build.SourcesDirectory)/$(FACheckoutFolder)/Src/FAPortalBusiness/Services/FAPortal.Services,$(Build.SourcesDirectory)/$(FACheckoutFolder)/Src/FAPortalCommon/FAPortal.Infrastructure,$(Build.SourcesDirectory)/$(FACheckoutFolder)/Src/FAPortalBusiness/BusinessLogic/FAPortal.Domain
    services.sonar.tests=$(Build.SourcesDirectory)/$(FACheckoutFolder)/Src/UnitTests/FAPortalBusiness/BusinessLogic/FAPortal.Domain.Tests
    sonar.branch.name=$(Build.SourceBranchName)
    sonar.cs.vstest.reportsPaths=$(Net6TestResults)//*.trx
    sonar.cs.opencover.reportsPaths=$(Agent.TempDirectory)/
    /*.opencover.xml
    sonar.exclusions=/bin/,/obj/,$(Build.SourcesDirectory)/$(FACheckoutFolder)/Src/FAPortalBusiness/BusinessLogic/FAPortal.Models/,/Models/**
    sonar.cs.analyzeGeneratedCode=true
    sonar.cs.ignoreHeaderComments=true

  • task: SonarCloudAnalyze@1
    displayName: ‘Run SonarCloud Analysis’

  • task: SonarCloudPublish@1
    displayName: ‘Publish Quality Gate Result’
    inputs:
    pollingTimeoutSec: ‘300’

Hello @shanemw,

Could you try running another analysis without setting the following parameters?

  • sonar.modules
  • services.sonar.projectName
  • services.sonar.projectBaseDir
  • services.sonar.sources
  • services.sonar.tests
  • sonar.branch.name

These parameters should be automatically detected by us.