How to inject sonar-project.properties into msbuild in sonarqube

sonarqube
msbuild
scanner

(r.kuma) #1

I have a c-sharp solution (say sample.sln), but to run sonarqube analysis, as per the docs, i have run the following command:

 ".\3rdparty\sonarqube\msbuild\SonarScanner.MSBuild.exe" begin /k:"comm" 
  /n:"comm" /v:"2.0" 
  /d:sonar.cs.dotcover.reportsPaths= 
  "D:\Jenkins\workspace\comm\TEST\CoverageReport.html" 
  /d:sonar.host.url="http://101.149.24.128"
  /d:sonar.sources="D:\Jenkins\workspace\comm\source\*.cs"

  msbuild comm.sln /t:Rebuild

  ".\3rdparty\sonarqube\msbuild\SonarScanner.MSBuild.exe" end

but getting this error :

  SONAR_SCANNER_OPTS is not configured. Setting it to the default value of -Xmx1024m
Calling the SonarQube Scanner...
INFO: Scanner configuration file: D:\Jenkins\workspace\comm\3rdparty\sonarqube\msbuild\sonar-scanner-3.2.0.1227\bin\..\conf\sonar-scanner.properties
INFO: Project root configuration file: D:\Jenkins\workspace\comm\.sonarqube\out\sonar-project.properties
INFO: SonarQube Scanner 3.2.0.1227
INFO: Java 1.8.0_151 Oracle Corporation (64-bit)
INFO: Windows Server 2016 10.0 amd64
INFO: SONAR_SCANNER_OPTS=-Xmx1024m
INFO: User cache: C:\Users\jenkins\.sonar\cache
INFO: SonarQube server 6.7.5
INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent)
INFO: Publish mode
INFO: Load global settings
INFO: Load global settings (done) | time=278ms
INFO: Server id: 7950B4AD-AWYRoMpRpurWib7aM-qP
INFO: User cache: C:\Users\jenkins\.sonar\cache
INFO: Load plugins index
INFO: Load plugins index (done) | time=84ms
INFO: Process project properties
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 13.565s
INFO: Final Memory: 6M/84M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: Unable to load component class org.sonar.scanner.scan.ProjectLock
ERROR: Caused by: Unable to load component class org.sonar.scanner.scan.DefaultInputModuleHierarchy
ERROR: Caused by: Unable to load component class org.sonar.scanner.scan.ProjectBuildersExecutor
ERROR: Caused by: Unable to load component class com.talanlabs.sonar.plugins.gitlab.CommitProjectBuilder
ERROR: Caused by: Unable to load component class com.talanlabs.sonar.plugins.gitlab.GitLabPluginConfiguration
ERROR: Caused by: Unable to load component class org.sonar.scanner.scan.MutableProjectSettings
ERROR: Caused by: Unable to load component class org.sonar.api.batch.bootstrap.ProjectReactor
**ERROR: Caused by: Illegal char <*> at index 43: D:\Jenkins\workspace\comm\source\*.cs**
ERROR: 
The SonarQube Scanner did not complete successfully

so i thought of adding, all the sonar related properties into sonar-project.properties, and kept inside the project root folder, and ran the analysis. but got an error below.

  sonar-project.properties files are not understood by the SonarScanner for MSBuild. Remove those files from the following folders: D:\Jenkins\workspace\comm.

what i could infer is, we cannot set sonar-project.properties for msbuild ? is it ?

So then how to do include/exclude files/folders from code coverage in sonar analysis ? I don’t have admin access, to set administrative global exclusions

Any help ?

P.S using sonarqube LTS 6.7.6