Unable to scan c# files with Sonar Scanner for .NET

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension):
    I am using SonarScanner for MSBuild 5.3.1 . SonarQube server version : * Enterprise Edition* Version 8.9.2 . I am building the application inside Docker container (OS Debian).
  • what are you trying to achieve:
    I am running these commands:

mono /tmp/sonar/SonarScanner.MSBuild.exe begin /k:’’ /n:’’ /d:sonar.host.url=’’ /d:sonar.login=’’ /d:sonar.verbose=true ;

/usr/bin/msbuild -m ./Unity/*******.sln -t: -tv:Current; rm -rf ./sonar-project.properties;

mono /tmp/sonar/SonarScanner.MSBuild.exe end /d:sonar.login=’$’

But I am receiving this error message:

Using the .NET Framework version of the Scanner for MSBuild
2021-10-25 16:39:49.757  Post-processing started.
2021-10-25 16:39:50.018  13:39:49.781  13:39:49.775  Uninstalling target: /usr/src/.sonarqube/bin/targets/SonarQube.Integration.targets
2021-10-25 16:39:50.018  13:39:49.781  13:39:49.781  sonar.verbose=true was specified - setting the log verbosity to 'Debug'
2021-10-25 16:39:50.018  13:39:49.782  Loading the SonarQube analysis config from /usr/src/.sonarqube/conf/SonarQubeAnalysisConfig.xml
2021-10-25 16:39:50.018  13:39:49.782  Not running under TeamBuild
2021-10-25 16:39:50.018  13:39:49.782  Analysis base directory: /usr/src/.sonarqube
2021-10-25 16:39:50.018  Build directory: 
2021-10-25 16:39:50.019  Bin directory: /usr/src/.sonarqube/bin
2021-10-25 16:39:50.019  Config directory: /usr/src/.sonarqube/conf
2021-10-25 16:39:50.019  Output directory: /usr/src/.sonarqube/out
2021-10-25 16:39:50.019  Config file: /usr/src/.sonarqube/conf/SonarQubeAnalysisConfig.xml
2021-10-25 16:39:50.019  13:39:49.784  Generating SonarQube project properties file to /usr/src/.sonarqube/out/sonar-project.properties
2021-10-25 16:39:50.019  13:39:49.793  The SonarScanner for MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
2021-10-25 16:39:50.019  Possible causes:
2021-10-25 16:39:50.019    1. The project has not been built - the project must be built in between the begin and end steps
2021-10-25 16:39:50.019    2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported.
2021-10-25 16:39:50.019    3. The begin, build and end steps have not all been launched from the same folder
2021-10-25 16:39:50.019    4. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
2021-10-25 16:39:50.019  13:39:49.793  Generation of the sonar-properties file failed. Unable to complete the analysis.
2021-10-25 16:39:50.019  13:39:49.798  Writing processing summary to /usr/src/.sonarqube/out/ProjectInfo.log
2021-10-25 16:39:50.019  13:39:49.8  Post-processing failed. Exit code: 1

Hi @tkanzova

Welcome to the community! Apologies for the late reply. Do you still have the problem?

If yes, we’ll need the logs:

  • please give us the verbose output of the scanner commands (please run SonarScanner.MSBuild.exe begin /k:“MyProject” /d:sonar.verbose=true as the begin step, and please attach the output of the BEGIN and END steps)
  • please give the output of running MSBuild in verbose mode (/v:d)

Also, please tell us:

  • what are the commands you are running to do the analysis?
  • are you running all commands from the same folder?