0

I am running SonarQube server v6.4 with v6.1 of the C# plugin. We have v3.0.0 of the SonarQube TFS extension installed in our TFS 2015 (Update 3) instance.

I am having issues with SonarQube scanning .cs files. There are a few warnings in the output of a few build steps that I'm not entirely sure what to make of. I haven't been able to find much on the messages.

Visual Studio Build step output:

        OverrideCodeAnalysisProperties:
          Skipping FxCop analysis: the SonarQube ruleset does not exist. Ruleset: C:\BuildAgents\Agent-01\_work\111\.sonarqube\conf\\SonarQubeFxCop-cs.ruleset

SonarQube Scanner for MSBuild - End Analysis (new) step output:

I'm seeing this at the beginning of the output for the step...

SonarQube Scanner for MSBuild 3.0 
Default properties file was found at C:\BuildAgents\Agent-01\tasks\SonarQubeScannerMsBuildBegin\3.0.0\SonarQubeScannerMsBuild\SonarQube.Analysis.xml 
Loading analysis properties from C:\BuildAgents\Agent-01\tasks\SonarQubeScannerMsBuildBegin\3.0.0\SonarQubeScannerMsBuild\SonarQube.Analysis.xml 
Post-processing started. 
17:58:54.965  17:58:54.965  WARNING: Failed to find the code coverage command line tool. Possible cause: Visual Studio is not installed, or the installed version does not support code coverage. 
WARNING: File is not under the project directory and cannot currently be analysed by SonarQube. File: C:\Users\TFS2015Build\AppData\Local\Temp\.NETFramework,Version=v4.5.2.SqlClrAttributes.cs, project: C:\BuildAgents\Agent-01\_work\111\s\FunProject.Db\FunProject.Db.sqlproj
SONAR_SCANNER_OPTS is not configured. Setting it to the default value of -Xmx1024m 
Calling the SonarQube Scanner... 
INFO: Scanner configuration file: C:\BuildAgents\Agent-01\tasks\SonarQubeScannerMsBuildBegin\3.0.0\SonarQubeScannerMsBuild\sonar-scanner-3.0.3.778\bin\..\conf\sonar-scanner.properties 
INFO: Project root configuration file: C:\BuildAgents\Agent-01\_work\111\.sonarqube\out\sonar-project.properties 
INFO: SonarQube Scanner 3.0.3.778 
INFO: Java 1.8.0_121 Oracle Corporation (64-bit) 
INFO: Windows Server 2012 R2 6.3 amd64  
INFO: SONAR_SCANNER_OPTS=-Xmx1024m 
INFO: User cache: C:\Users\TFS2015Build\.sonar\cache 
INFO: Load global settings 
INFO: Load global settings (done) | time=125ms 
INFO: User cache: C:\Users\TFS2015Build\.sonar\cache 
INFO: Load plugins index 
INFO: Load plugins index (done) | time=0ms 
INFO: Download sonar-csharp-plugin-6.1.0.2359.jar 
INFO: Download sonar-python-plugin-1.8.0.1496.jar 
INFO: Download sonar-java-plugin-4.11.0.10660.jar 
INFO: Download sonar-flex-plugin-2.3.jar 
INFO: Download sonar-scm-git-plugin-1.2.jar 
INFO: Download sonar-xml-plugin-1.4.3.1027.jar 
INFO: Download sonar-php-plugin-2.10.0.2087.jar 
INFO: Download sonar-scm-svn-plugin-1.4.0.522.jar 
INFO: Download sonar-javascript-plugin-3.1.1.5128.jar 
INFO: SonarQube server 6.4.0 
INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent) 
INFO: Process project properties 
INFO: Load project repositories 
INFO: Load project repositories (done) | time=141ms 
INFO: Load quality profiles 
INFO: Load quality profiles (done) | time=47ms 
INFO: Load active rules 
INFO: Load active rules (done) | time=281ms 
INFO: Load metrics repository 
INFO: Load metrics repository (done) | time=78ms 
INFO: Publish mode

...then I'm seeing a set of output like this for each project in my solution:

 INFO: -------------  Scan FunProject.Shared 
 INFO: Load server rules 
 INFO: Load server rules (done) | time=156ms 
 INFO: Initializer GenericCoverageSensor 
 INFO: Initializer GenericCoverageSensor (done) | time=0ms 
 INFO: Base dir: C:\BuildAgents\Agent-01\_work\111\s\FunProject.Shared 
 INFO: Working dir: C:\BuildAgents\Agent-01\_work\111\.sonarqube\out\.sonar\mod13 
 INFO: Source paths: FunProjectFolder1/FunProjectClassFile1.cs, FunProjectFolder2/FunProjectClassFile2.cs, ... Properties/AssemblyInfo.cs, packages.config 
 INFO: Source encoding: UTF-8, default locale: en_US 
 INFO: Index files 
 INFO: Analyzer working directory does not exist 
 INFO: 12 files indexed 
 INFO: Quality profile for cs: Sonar way 
 INFO: Sensor C# [csharp] 
 INFO: Importing analysis results from C:\BuildAgents\Agent-01\_work\111\.sonarqube\out\FunProject.Shared_3389\output-cs 
 WARNING: WARN: Protobuf file not found: C:\BuildAgents\Agent-01\_work\111\.sonarqube\out\FunProject.Shared_3389\output-cs\encoding.pb 
 INFO: Importing Roslyn report 
 WARNING: WARN: Protobuf file not found: C:\BuildAgents\Agent-01\_work\111\.sonarqube\out\FunProject.Shared_3389\output-cs\metrics.pb 
 WARNING: WARN: Protobuf file not found: C:\BuildAgents\Agent-01\_work\111\.sonarqube\out\FunProject.Shared_3389\output-cs\token-type.pb 
 WARNING: WARN: Protobuf file not found: C:\BuildAgents\Agent-01\_work\111\.sonarqube\out\FunProject.Shared_3389\output-cs\symrefs.pb 
 WARNING: WARN: Protobuf file not found: C:\BuildAgents\Agent-01\_work\111\.sonarqube\out\FunProject.Shared_3389\output-cs\token-cpd.pb 
 INFO: Sensor C# [csharp] (done) | time=78ms 
 INFO: Sensor SonarJavaXmlFileSensor [java] 
 INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=0ms 
 INFO: Sensor Analyzer for "php.ini" files [php] 
 INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=0ms

Is there something obvious that I'm missing?

Edit:

I am using Visual Studio Professional, so the warning about code coverage is caused by the fact that I do not have Visual Studio Enterprise installed on the build server.

aoggz
  • 1
  • 1
  • 3

2 Answers2

0

Suggest you first try to analyze solution in the command line locally to see if it works.

Run your analysis by executing the following commands from the root directory of the project:

SonarQube.Scanner.MSBuild.exe begin /k:"org.sonarqube:sonarqube-scanner-msbuild" /n:"Project Name" /v:"1.0"
MSBuild.exe /t:Rebuild
SonarQube.Scanner.MSBuild.exe end

This will narrow down it's your environment issue or just related to your build definition settings.

According to the error message:

WARNING: Failed to find the code coverage command line tool. Possible cause: Visual Studio is not installed, or the installed version does not support code coverage.

Double check your VS edition on your build agent. Note: you need Visual Studio Enterprise edition for code coverage. Have a look at this page and expand the 'testing tools' section. Code coverage is only listed for the Enterprise edition.

Besides, you could also enable verbose Debug Mode with system.debug=true to get a more detail build log for troubleshooting.

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • Thanks for the input. I did try your suggestion and achieved the same result, unfortunately. And to your point about code coverage, we are using VS Professional, so the latter portion of the message is applicable. I've updated my original question to reflect this understanding. – aoggz Jul 13 '17 at 12:46
  • @aoggz If so, seems this issue is not related to TFS, but with your build agent environment. Also run the SonarQube analysis on your local environment, if this succeed, compare the environment each other. Are you building your solution with msbuild12 or msbuild14 ,15? Try to use the latest version of msbuild and also, please double check the path of msbuild. Besides check the .cs file is read only or not? Test it with remove read only status. – PatrickLu-MSFT Jul 13 '17 at 13:53
  • I did the same exercise on my local machine. I used MSBuild 14 locally, which is what is installed on the server. I also tried with MSBuild 15 locally even though VS 2017 is not yet installed on our build server. I also ran `attrib -R ./* /S` to remove the read only flag. All attempts have yielded the same result. – aoggz Jul 14 '17 at 11:14
0

I downgraded the C# plugin from 6.1 (build 2359) to 5.11 (build 1721), and the problem went away. There must be some issue with that release that was causing the issue.

aoggz
  • 1
  • 1
  • 3
  • I think I might be having the same issue. How did you downgrade the plugin. I didn't see an option to do so, and when I tried to re-install it, I couldn't find a way to pick a version. – Ashwin Chandran Aug 22 '17 at 17:25
  • All you have to do is uninstall the plugin, download the version of the plugin you want, and put it in the plugins directory of your SonarQube server. The server UI doesn't support a way to install non-latest versions of plugins. More info at https://docs.sonarqube.org/display/SONAR/Installing+a+Plugin. – aoggz Aug 23 '17 at 22:20