We are using GitHub Actions in our organization to integrate with Sonar Cloud.
We use the dotnet scanner.
We are reusing exactly the same action code among our repositories, nevertheless, in some of them we are getting the following warning: SCM provider autodetection failed. Please use “sonar.scm.provider” to define SCM of your project, or disable the SCM Sensor in the project settings.
Having a deeper look into sonar scanner logs, I’ve identified that the ones with this warning have wrong Base dir when compared with the ones working properly:
The faulty ones are like:
Base dir: /
and the correct ones are like:
Base dir: /home/runner/work/REPO_NAME/REPO_NAME
The .NET Scanner tried to calculate this from here:
/// Appends the sonar.projectBaseDir value. This is calculated as follows:
/// 1. the user supplied value, or if none
/// 2. the sources directory if running from TFS Build or XAML Build, or
/// 3. the common path prefix of projects in case there's a majority with a common root, or
/// 4. the .sonarqube/out directory.
Can you turn on DEBUG level logging for the .NET Scanner (/d:sonar.verbose=true) and check the logs to see how it’s being calculated?