SonarQube 插件在 TFS 构建期间不扫描 C# 文件
SonarQube plug-in not scanning C# files during TFS Build
我是 运行 SonarQube 服务器 v6.4 和 v6.1 的 C# 插件。我们在 TFS 2015(更新 3)实例中安装了 SonarQube TFS extension 的 v3.0.0。
我在使用 SonarQube 扫描 .cs 文件时遇到问题。一些构建步骤的输出中有一些警告,我不完全确定该怎么做。我没能在消息中找到太多信息。
Visual Studio构建步输出:
OverrideCodeAnalysisProperties:
Skipping FxCop analysis: the SonarQube ruleset does not exist. Ruleset: C:\BuildAgents\Agent-01\_work1\.sonarqube\conf\SonarQubeFxCop-cs.ruleset
SonarQube Scanner for MSBuild - 结束分析(新) 步骤输出:
我在步骤输出的开头看到了这个...
SonarQube Scanner for MSBuild 3.0
Default properties file was found at C:\BuildAgents\Agent-01\tasks\SonarQubeScannerMsBuildBegin.0.0\SonarQubeScannerMsBuild\SonarQube.Analysis.xml
Loading analysis properties from C:\BuildAgents\Agent-01\tasks\SonarQubeScannerMsBuildBegin.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\_work1\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.0.0\SonarQubeScannerMsBuild\sonar-scanner-3.0.3.778\bin\..\conf\sonar-scanner.properties
INFO: Project root configuration file: C:\BuildAgents\Agent-01\_work1\.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
...然后我在我的解决方案中为每个项目看到一组这样的输出:
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\_work1\s\FunProject.Shared
INFO: Working dir: C:\BuildAgents\Agent-01\_work1\.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\_work1\.sonarqube\out\FunProject.Shared_3389\output-cs
WARNING: WARN: Protobuf file not found: C:\BuildAgents\Agent-01\_work1\.sonarqube\out\FunProject.Shared_3389\output-cs\encoding.pb
INFO: Importing Roslyn report
WARNING: WARN: Protobuf file not found: C:\BuildAgents\Agent-01\_work1\.sonarqube\out\FunProject.Shared_3389\output-cs\metrics.pb
WARNING: WARN: Protobuf file not found: C:\BuildAgents\Agent-01\_work1\.sonarqube\out\FunProject.Shared_3389\output-cs\token-type.pb
WARNING: WARN: Protobuf file not found: C:\BuildAgents\Agent-01\_work1\.sonarqube\out\FunProject.Shared_3389\output-cs\symrefs.pb
WARNING: WARN: Protobuf file not found: C:\BuildAgents\Agent-01\_work1\.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
有什么明显的我遗漏的东西吗?
编辑:
我正在使用 Visual Studio Professional,所以有关代码覆盖率的警告是由于我没有在构建服务器上安装 Visual Studio Enterprise。
建议您先尝试在本地命令行分析解决方案,看看是否有效。
运行 通过从项目的根目录执行以下命令进行分析:
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
这将缩小是您的环境问题还是仅与您的构建定义设置有关的问题。
根据报错信息:
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.
仔细检查您在构建代理上的 VS 版本。 注意:您需要Visual Studio企业版以实现代码覆盖率。查看 this page 并展开“测试工具”部分。仅列出企业版的代码覆盖率。
此外,您还可以启用 verbose Debug Mode 和 system.debug=true
以获得更详细的构建日志以进行故障排除。
我将 C# 插件从 6.1(内部版本 2359)降级到 5.11(内部版本 1721),问题消失了。导致问题的那个版本一定有问题。
我是 运行 SonarQube 服务器 v6.4 和 v6.1 的 C# 插件。我们在 TFS 2015(更新 3)实例中安装了 SonarQube TFS extension 的 v3.0.0。
我在使用 SonarQube 扫描 .cs 文件时遇到问题。一些构建步骤的输出中有一些警告,我不完全确定该怎么做。我没能在消息中找到太多信息。
Visual Studio构建步输出:
OverrideCodeAnalysisProperties:
Skipping FxCop analysis: the SonarQube ruleset does not exist. Ruleset: C:\BuildAgents\Agent-01\_work1\.sonarqube\conf\SonarQubeFxCop-cs.ruleset
SonarQube Scanner for MSBuild - 结束分析(新) 步骤输出:
我在步骤输出的开头看到了这个...
SonarQube Scanner for MSBuild 3.0
Default properties file was found at C:\BuildAgents\Agent-01\tasks\SonarQubeScannerMsBuildBegin.0.0\SonarQubeScannerMsBuild\SonarQube.Analysis.xml
Loading analysis properties from C:\BuildAgents\Agent-01\tasks\SonarQubeScannerMsBuildBegin.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\_work1\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.0.0\SonarQubeScannerMsBuild\sonar-scanner-3.0.3.778\bin\..\conf\sonar-scanner.properties
INFO: Project root configuration file: C:\BuildAgents\Agent-01\_work1\.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
...然后我在我的解决方案中为每个项目看到一组这样的输出:
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\_work1\s\FunProject.Shared
INFO: Working dir: C:\BuildAgents\Agent-01\_work1\.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\_work1\.sonarqube\out\FunProject.Shared_3389\output-cs
WARNING: WARN: Protobuf file not found: C:\BuildAgents\Agent-01\_work1\.sonarqube\out\FunProject.Shared_3389\output-cs\encoding.pb
INFO: Importing Roslyn report
WARNING: WARN: Protobuf file not found: C:\BuildAgents\Agent-01\_work1\.sonarqube\out\FunProject.Shared_3389\output-cs\metrics.pb
WARNING: WARN: Protobuf file not found: C:\BuildAgents\Agent-01\_work1\.sonarqube\out\FunProject.Shared_3389\output-cs\token-type.pb
WARNING: WARN: Protobuf file not found: C:\BuildAgents\Agent-01\_work1\.sonarqube\out\FunProject.Shared_3389\output-cs\symrefs.pb
WARNING: WARN: Protobuf file not found: C:\BuildAgents\Agent-01\_work1\.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
有什么明显的我遗漏的东西吗?
编辑:
我正在使用 Visual Studio Professional,所以有关代码覆盖率的警告是由于我没有在构建服务器上安装 Visual Studio Enterprise。
建议您先尝试在本地命令行分析解决方案,看看是否有效。
运行 通过从项目的根目录执行以下命令进行分析:
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
这将缩小是您的环境问题还是仅与您的构建定义设置有关的问题。
根据报错信息:
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.
仔细检查您在构建代理上的 VS 版本。 注意:您需要Visual Studio企业版以实现代码覆盖率。查看 this page 并展开“测试工具”部分。仅列出企业版的代码覆盖率。
此外,您还可以启用 verbose Debug Mode 和 system.debug=true
以获得更详细的构建日志以进行故障排除。
我将 C# 插件从 6.1(内部版本 2359)降级到 5.11(内部版本 1721),问题消失了。导致问题的那个版本一定有问题。