Error on scanning: No analysable projects were found. SonarQube analysis will not be performed

vscode
visualstudio
dotnet
sonarqube
(Vci Am Sa) #1

I’m trying to analyze a VS2017 solution with Sonarqube. I’ve installed Sonarqube server on a VM with Windows 2016 ( Community Edition Version 7.6 (build 21501)).
I’ve created a batch file in the root of the solution with the command suggested by the Sonarqube server when creating the project:
The batch file contains the following command:

    SonarScanner.MSBuild.exe begin /k:"MyProject" /d:sonar.host.url="http://sonarqubeserver:9002" /d:sonar.login="KeyProvidedByServer"

    "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MsBuild.exe" 

    D:\Source\Repos\Project\MyProject.sln /t:Rebuild
        SonarScanner.MSBuild.exe end /d:sonar.login="KeyProvidedByServer"

When I launch the batch file from command prompt with administrative privileges the first and second command run correctly but the third ends up with a tons of lines like:

WARNING: File ‘D:\Source\Repos\Project\MyProject\class.cs’ is not located under the root directory ‘D:\Source\Repos\Project\.sonarqube\out’ and will not be analyzed.

and a final message

_File was referenced by the following projects: ‘D:\Source\Repos\Project\Project\MyProject.csproj’.*

No analysable projects were found. SonarQube analysis will not be performed. Check the build summary report for details.

Writing processing summary to

D:\Source\Repos\Project\.sonarqube\out\ProjectInfo.log Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.

12:13:35.099 Creating a summary markdown file…

_12:13:35.103 Post-processing failed. Exit code: 1-

Anyone can help me correct the error?

2 months I’ve posted this and really anyone can help me?

(Andrei Epure) #2

Sorry for the delay. Could you show us the file directory structure? Maybe you’re not running the commands from the correct directory?

(Vci Am Sa) #3

Thanks, I’ve solved using Azure Devops and the SonarQube plugin, installing a SonarQube server on a Virtual Machine.

Anyway I was running the command from the Root directory of the Visual Studio Solution, where the .sln file reside.

1 Like