Sonarcloud not analyzing non-test C# project

Hi,

I’m struggling with a project of mine that, when analyzed, returns no source code at all (and hence analyzes naught).

I’m using MSBuild-integrated analyzer in a yaml-based build in Azure DevOps.

I suspected the issue was due to my project being named AddUp.RabbitMQ.Fakes (the fakes part may collide with the test project detection logic somehow). So I tried to force this project to be considered worth analyzing by adding this to AddUp.RabbitMQ.Fakes.csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    ...
    <SonarQubeTestProject>false</SonarQubeTestProject>
    <SonarQubeExclude>false</SonarQubeExclude>
  </PropertyGroup>

Alas, all my attemps failed: Azure DevOps log keeps telling me this for the analysis step:

The exclude flag has been set so the project will not be analyzed by SonarQube. Project file: D:\a\1\s\src\AddUp.RabbitMQ.Fakes\AddUp.RabbitMQ.Fakes.csproj
The exclude flag has been set so the project will not be analyzed by SonarQube. Project file: D:\a\1\s\src\AddUp.RabbitMQ.Fakes.Tests\AddUp.RabbitMQ.Fakes.Tests.csproj
##[error]No analysable projects were found. SonarQube analysis will not be performed. Check the build summary report for details.
No analysable projects were found. SonarQube analysis will not be performed. Check the build summary report for details.
Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
##[error]10:43:53.561  Post-processing failed. Exit code: 1
10:43:53.561  Post-processing failed. Exit code: 1
##[error]The process 'D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.10.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe' failed with exit code 1
Finishing: Sonarcloud - Analyze

For reference,

Hope someone can help.
Thanks!

Hi @odalet,

<SonarQubeTestProject>false</SonarQubeTestProject>
    <SonarQubeExclude>false</SonarQubeExclude>

Those bose flags are mutually exclusive, so you need to put one or the other, not both at the same time, and, in you case, only false should do the trick.

HTH,
Mickaël

Hi, and thanks for the prompt reply, however, that does not work better:

The exclude flag has been set so the project will not be analyzed by SonarQube. Project file: D:\a\1\s\src\AddUp.RabbitMQ.Fakes\AddUp.RabbitMQ.Fakes.csproj

Attached is the full log for the analysis step: 12.txt (15.1 KB)

To be clearer I simply kept <SonarQubeExclude>false</SonarQubeExclude> in the csproj.

This one will exclude the project from the analysis, i’m not sure this is the one that you want ?

By the way I tried both:

  • Keeping only <SonarQubeExclude>false</SonarQubeExclude> or
  • Keeping only <SonarQubeTestProject>false</SonarQubeTestProject>

Neither option works :frowning:

I just did a quick test, and it appears that we have a slight bug in our detection for specifically fakes projects.

I opened an issue in our repository : https://github.com/SonarSource/sonar-scanner-msbuild/issues/844

This will be fixed soon.

Do you use Microsoft-hosted agents for your build, or you host them by yourself ?

Thank you.
Mickaël

I’m using a Microsoft-hosted agent (on the free plan).
Thanks for investigating. I’ll track the github issue (and provide additional data if I can over there).

Thanks again!