AzureDevops MSBuild analyses whole dotnet solution instead of changed files in PR pipeline

Hi, we’ve been using Sonar cloud analysis for a while now, it’s worked great, after the initial repo analysis it would only scan and report issues within files where we had new code.
However, a month ago or so, it started fully scanning the repo on every pipeline run, reporting all of the issues constantly and since we have some technical debt, this has made it unusable.

Our New code definition config is:
Number of days: 30

AzureDevOps
Project is dotnet c#

This is our PR pipeline config, which hasn’t been changed since we adopted SC a while back.

      - task: JavaToolInstaller@0
        inputs:
          versionSpec: '17'
          jdkArchitectureOption: 'x64'
          jdkSourceOption: 'PreInstalled'

      - task: SonarCloudPrepare@1
        inputs:
          SonarCloud: SonarCloud
          organization: {redacted_organization}
          scannerMode: MSBuild
          projectKey: {redacted_project_key}
          projectName: {redacted_project_name}

      - task: SonarCloudAnalyze@1
        inputs:
          jdkversion: 'JAVA_HOME'
      - task: SonarCloudPublish@1
        inputs:
          pollingTimeoutSec: '300'

Hey there.

Have you continued to run analysis of your main branch since first adopting SonarCloud?

Hi Colin,

we had a different pipeline which used to run analysis on our main branch, but that’s been dropped, so we are currently just running analysis in the PR pipeline.

Roberto

I think that’s the ticket – the scanner is comparing your target branch analyzed on SonarCloud, and if it’s not up to date, the diff won’t be correct.

Hi Colin,

Thanks for quick reply, we will set up new pipeline trigger to continuously analyse our main branch on any change.
I will let you know if that solves our issue.

Kind regards,
Roberto

1 Like

Hi Colin,

We made changes to our pipeline as per your suggestion, it all works as expected now.
Thanks a mil and happy holidays!

Kind regards,
Roberto

Likewise!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.