We have been successfully using Sonarqube for a number of years with our .NET applications.
On our latest project we are encountering an issue where we get this message:
‘The main branch of this project is empty.’
This new project initially had a ‘main’ branch and Sonarqube was run against this branch. We have since created a new ‘master’ branch and removed the ‘main’ branch.
We have tried deleting the project and rerunning the analysis and we have updated our azure pipelines to include:
First, sonar.projectCreation.mainBranchName cannot be set in analysis properties. It’s a global property and can only be set, at the global level, in the UI.
But on that topic, what is your global property set to?
Are you talking about the Default main branch name in the administration section?
Default main branch name
Each project has a main branch at creation. This setting defines the instance-wide default main branch name. A user can override this when creating a project. This setting does not apply to projects imported from a DevOps platform.
That is set to master although the guidance suggests the branch will be picked up devops, which is what we use.
Okay, so your project initially had a main branch but now has a master branch. You’ve deleted it and reanalyzed and you see this “main branch… is empty” message.
What shows up in the branches dropdown? Does master show up in the list as a non-main branch?
And can you post your master analysis log?
The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.
I am just confirming with our support guys that its ok send the file. What i have noticed in the analysis file is that all the source code is skipped to it being a test file?
Example:
2024-09-26T07:20:25.5005849Z 07:20:25.495 DEBUG: Skipping ‘/__w/26/s/Imagesound.Remote.Api/Extensions/ControllerExtensions.cs’ as it is a test file.