Sonarcloud - some csproj projects are not being shown in analysis

Using sonarcloud on azure pipelines build

If I build with pipeline build A (using SLN A) all the csproj projects I would expect to see appear
If I build with pipeline build B (using SLN B), the extra csproj projects I would expect to see do not appear

in the pipelines build for B I can see the below parts so its finding the code etc

SonarCategoriseProject:
Sonar: (CISIWeb2.csproj) Categorizing project as test or product code…
Unable to parse assembly name ‘@()’
Sonar: (CISIWeb2.csproj) categorized as MAIN project (production code).
SonarCreateProjectSpecificDirs:
Creating directory “D:\a\1.sonarqube\conf\19”.
SonarWriteFilesToAnalyze:
Sonar: (CISIWeb2.csproj) Number of files to analyse: 1724. The list of files to be analyzed is in D:\a\1.sonarqube\conf\19\FilesToAnalyze.txt.
SetRoslynCodeAnalysisProperties:
Sonar: (CISIWeb2.csproj) Analysis configured successfully with D:\a\1.sonarqube\conf\19\SonarProjectConfig.xml.
SonarQubeImportBeforeInfo:
Sonar: (CISIWeb2) SonarQube.Integration.ImportBefore.targets was loaded

SonarWriteProjectData:
Sonar: (CISIWeb2.csproj) Project processed successfully

Hi @whiterabbit99 welcome to the community.

Can you tell us which version of the Scanner for .NET you are using please ?

Thanks.

Hi @mickaelcaro where do I find the version? I assumed the sonarcloud jobs in Azure Devops pipelines always used the newest versions - using these:

SonarCloudPrepare@1
SonarCloudAnalyze@1
SonarCloudPublish@1

It’s written at the top of the prepare or analyze log basically.

So what are those extra csproj in SLN B that do not appear ? Are they classic projects with product code ?

You can check which projects/files have been indexed by issuing a build using the system.debug=true build variable. Then on the Analyze task logs, you’ll have a dump of the sonar-project.properties that has been generated, containing everything that will be analyzed just after.

Mickaël

ok so the versions are this:

Task : Prepare Analysis Configuration
Description : Prepare SonarCloud analysis configuration
Version : 1.21.0
Author : sonarsource
Help : Version: 1.21.0. More Information

OK I have 2 Azure Devops Pipelines - cisi and cisiweb2…

  • The cisiweb2 pipelines builds the cisiweb2.sln which includes cisiweb2 project (cisiweb2.csproj) and related projects each in a folder with the same name eg /cisiweb2
  • The cisi pipeline builds the cisi.sln which builds various projects
  • Some shared projects such as cisi.shared.csproj are in both sln files so would be built by both pipelines
  • csproj projects are a mix of old style and new style sdk (eg .net standard 2.0 and .net core projects)
  • for the purposes of this all projects are c# based csproj
  • All the files including the 2 sln files are in the same GIT repository on Azure Devops
  • I already had a cisiweb2 pipeline build with the debug options so can see the paths in the sonar-project .properties dump:

example line in cisiweb2 pipeline build:
“D:\a\1\s\CISIWeb2\Mvc\Models\ElearningAttemptDetails.cs”,\

The cisiweb2 build does not include the cpd project and as expected I don’t see anything from cpd folder in the dump

As far as I can see each pipeline build is overwriting what was placed in sonarqube by the previous one so I need a way of stopping this

OK so thats exactly what is happening:

  1. currently the cisiweb2 pipeline is the most recent to complete and in sonarcloud I can see all its projects
  2. when the cisi pipeline (currently building) finishes, then many of the above projects will disappear from sonarcloud and be replaced by the projects from the cisi pipeline

I need it so the 2 aren’t fighting and all the projects from both pipelines are showing up

Ok so definitely you’ll have 2 choices :

  • Either create a separate SonarCloud project for both pipeline
  • Or try to have everything built in the same sln : the reason why is that we don’t currently support partial analyses, meaning that if you do :
  • SC Prepare
  • Build SLN1
  • SC Analyze
  • SC Prepare
  • Build SLN2
  • SC analyze

both targetting the same SonarCloud project, then you fall into what you whitnessed ie the latest project to send its report will overwrite everything.

HTH,

1 Like

OK I think I got it sorted by using the Monorepo setup and then setting each pipeline SonarCloudPrepare@1 to have a different projectKey and projectName

1 Like

Did your project file contains a guid? It needs one before it can do a scan

As in guid for each project in the csproj files? If so yes they are there

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