Languages of the repository: .Net framework 4.8, C#
Version: Developer Edition License
Issue: Analyze not running for C# files. Only CSS file are showing in lines count.
I am having an issue in running analysis on C# files with the below error in Sitefinity application. I tried inclusion of .cs files and adding scannerMode: ‘MSBuild’ in additional properties but both didn’t help.
I am using Sonar Cloud extension for Azure DevOps where I don’t see option to update the sonar scanner version. Kindly advise where I have to update the scanner.
Prepare for Sonar Analysis YAML in Azure DevOps build pipeline:
steps:
- task: SonarSource.sonarcloud.14d9cde6-c1da-4d55-aa01-2965cd301255.SonarCloudPrepare@1
displayName: 'Prepare analysis on SonarCloud'
inputs:
SonarCloud: 'Sonar Cloud'
organization: 'kxxxxk'
projectKey: 'KXXXXK_KXXXK'
projectName: KxxxxxK
extraProperties: |
# Additional properties that will be passed to the scanner,
# Put one key=value per line, example:
# sonar.exclusions=**/*.bin
scannerMode: 'MSBuild' --> 'tried adding but didnt help.'
Your pipeline indicates that you’re running the prepare step. What comes after that? Because the error you’re seeing is not about scanner version, but about scanner flavor. Perhaps the docs will help.
Thanks for the log. I can’t believe I didn’t remember earlier, but one common cause of C# code being ignored is that it gets characterized as test code. And sure enough, here it is in your log:
2023-07-20T14:12:37.6386031Z Sonar: (kxxxxx.Services.csproj) Categorizing project as test or product code...
2023-07-20T14:12:37.6961707Z Sonar: (kxxxxx.Services.csproj) project is evaluated as a test project based on the 'Moq' reference.
2023-07-20T14:12:37.6962528Z Sonar: (kxxxxx.Services.csproj) categorized as TEST project (test code).
It happens over and over again, once for each project.