I am using Standalone scanning option in Prepare analysis on SonarQube task in Azure DevOps CI for .Net project.
I am using Self-hosted agent.
There are some constraint of using MSbuild scanning so we selected Standalone as a scan option.
When I run the CI pipeline and after successfully scanning the code and publishing the report if I check the report on SonarQube Dashboard I get the message “The main branch has no lines of code”.
If i check the Logs for Run code Analysis each and every files are getting scanned and indexed properly than to i am getting the above error.
Hi @chirag.ashiyani ,
Welcome to SonarSource Community!
Please add sonar.verbose=true to the extraProperties key in SonarQubePrepare task with Azure pipelines yaml and share the logs here.
If you want a quick solution that may not necessarily pertain to your problem, you can try this solution by setting
sonar.scm.exclusions.disabled=true, but you should check your logs first.
logs.txt (69.7 KB)
Please find attached Log.
I tried adding sonar.scm.exclusions.disabled=true than too the same error on Sonarqube Dashboard.
@chirag.ashiyani : Sorry, I reread your opening post. You should not use “Standalone” as scan option for your MSBuild or .NET project. You need to use
MSBuild for scanner mode. What constraint are you encountering? Can you show the original set of logs with your issue? Please add
SonarQubePrepare task to get debug logs. Please also show your azure pipeline yaml.
I am getting a strange behavior in SonarQube.
If I run the SonarQube using azure devops CI on my Feature branch it will give pass and have some result on dashboard.
Same if i run on the master branch i am getting The main branch has no lines of code.
Please find screen shot.
Azure DevOps CI pipeline:
CI-Pipeline.txt (8.5 KB)
logRunCodeAnalysis.txt (638.2 KB)
Hi @chirag.ashiyani ,
I see files indexed, but none of them were scanned for C# because you are using the standalone scanning option:
2021-04-23T12:13:06.1168921Z [command]C:\Windows\system32\cmd.exe /D /S /C "C:\agent\vsts-agent-win-x64-2.183.1\_work\_tasks\SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055\4.19.0\sonar-scanner\bin\sonar-scanner.bat -X" ... 2021-04-23T12:13:20.6746871Z 00:13:20.439 INFO: 1985 files indexed ... 2021-04-23T12:13:32.4979274Z 00:13:31.492 INFO: Sensor C# [csharp] 2021-04-23T12:13:32.4980002Z 00:13:31.492 INFO: Sensor C# [csharp] (done) | time=0ms
You cannot analyze C# files with
standalone scanner. Please use the
MSBuild scanner within the
SonarrQubePrepare task. Here’s an example:
trigger: - main pool: vmImage: 'macOS-latest' steps: - task: SonarQubePrepare@4 inputs: SonarQube: 'sq-service-connection85' scannerMode: 'MSBuild' projectKey: 'blorc-openidconnect' projectName: 'blorc-openidconnect' extraProperties: | sonar.verbose=true - task: DotNetCoreCLI@2 inputs: command: 'build' projects: 'src/Blorc.OpenIdConnect.sln' arguments: /nowarn:S4834,S4136,S125,S1135,S1128,S3903 - task: SonarQubeAnalyze@4 - task: SonarQubePublish@4 inputs: pollingTimeoutSec: '300'