Sonarsource not generating report through Azure devops

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube Version - Developer edition

  • what are you trying to achieve
    We have hosted sonarqube on Azure VM and we are trying to run code analysis and get Quality gate
    results through pipelines in devops.

  • what have you tried so far to achieve this
    We created new project in sonarQube and using Project Key and Authentication code we have
    setup the sonarqube configuration in Devops pipeline by creating a new service connection to Sonar
    endpoint server. We are successful to get Quality gate results of small solutions but we are not able
    to achieve
    the same for one of the solution while all the projects are build in .net framework.

Hey there.

So… what happens when you try? :smiley: What error do you face / what isn’t working as expected?

Hi Colin,

All the sonarQube task (Running code analysis and Publish quality gate results) were successful in devops pipeline but in SonarQube portal project is empty shows below message
The main branch has no lines of code.

Typically, that’s seen in two cases.

  • When the standalone scanner is used to analyze C# code (rather than integrating with MSBuild. You can check this in your Prepare Analysis Configuration build step.
  • Your Visual Studio projects are being classified as “Test” projects containing test code due to some bad configuration in your project files or the detection on our side. Check out this documentation to understand more.
    – You might see log messages like this when your code is built, to confirm it:

Sonar: (SonarQubeHelloWorld.csproj) Categorizing project as test or product code…
Sonar: (SonarQubeHelloWorld.csproj) project has the ProjectCapability ‘TestContainer’ -> test project
Sonar: (SonarQubeHelloWorld.csproj) Project categorized. SonarQubeTestProject=true

Hi Colin,

Thanks for reply.

  1. I have verified as suggested and can confirm we have configured integration with MSBuild.

  2. Verified the Pipeline Build logs for all the projects inside solution.

For all projects i can see SonarQubeTestProject=False

2021-01-11T05:25:41.7217506Z SonarQubeCategoriseProject:
2021-01-11T05:25:41.7217835Z Sonar: (SEyc.Frameworks.RequestProcess.ADOApi.csproj) Categorizing project as test or product code…
2021-01-11T05:25:41.7255459Z Sonar: (SEyc.Frameworks.RequestProcess.ADOApi.csproj) Project categorized. SonarQubeTestProject=False

Except the actual test projects -
2021-01-11T05:31:32.6128572Z SonarQubeCategoriseProject:
2021-01-11T05:31:32.6128884Z Sonar: (SEyc.Apps.Cluster.Tests.csproj) Categorizing project as test or product code…
2021-01-11T05:31:32.6135666Z Sonar: (SEyc.Apps.Cluster.Tests.csproj) project has the ProjectCapability ‘TestContainer’ -> test project
2021-01-11T05:31:32.6136397Z Sonar: (SEyc.Apps.Cluster.Tests.csproj) Project categorized. SonarQubeTestProject=true

We can share the build logs ,let me know if required

That’d be great!

Hi Colin,
Logs attached (2.2 MB)

Cool. Those are your build logs and we see the analyzers running. How about your SonarQube analysis logs, which probably ran right after the build?

Please find the Analysis log

Sonar-Analysis.txt (140.2 KB)

Ah, there we go. :slight_smile:

2021-01-12T11:41:49.1527658Z INFO: 0 files indexed
2021-01-12T11:41:49.1528007Z INFO: 15839 files ignored because of scm ignore settings 

There’s probably something funny in a .gitignore file somewhere. Is there one in this repository, can you provide it?

In the meantime, I bet if you set sonar.scm.exclusions.disabled=true as an additional analysis parameter you will see your files appear.

Hi Colin,

I have attached the gitignore file.

I am bit new to this , can you please guide me where to add this

gitignore.txt (5.9 KB)

Is this the one ??

You should be able to add it under Additional Analysis Parameters in your Prepare Analysis Configuration task on Azure Devops.

Hi Colin,

We are able to generate the Quality gate report. Thanks for all you help and support.