【问题标题】:SonarQube.Runner not compatible with C# pluginSonarQube.Runner 与 C# 插件不兼容
【发布时间】:2015-10-15 06:06:54
【问题描述】:

我正在尝试按照此处的说明获取以下 Sonar C# 插件:http://docs.sonarqube.org/display/PLUG/C%23+Plugin

服务器上安装的 C# 插件与 MSBuild.SonarQu 不兼容 be.Runner.exe - 检查兼容性矩阵或获取最新版本 对彼此而言。 预处理失败。退出代码:1"

在运行步骤 6)a 时:

MSBuild.SonarQube.Runner.exe begin /k:"sonarqube_project_key" 
/n:"sonarqube_project_name" /v:"sonarqube_project_version"
  • 我已试用 SonarQube 版本 4.5.4 (LTS) 和 5.1.1
  • VS2012 的开发者命令提示符
  • 我安装了java(oracle):jdk-8u51-windows-x64.exe
  • Microsoft (R) Build Engine 版本 4.0.30319.34209
  • 在 Windows server 2012 上运行

关于如何解决这个问题的任何想法?

谢谢


来自 MrFox:

我已经为这个问题添加了一个赏金,并在这里添加我关于这个问题的问题:

  1. 我需要制作 SonarQube 项目还是“SonarQube_project_key”是指我希望 SonarQube 扫描的 Visual Studio 项目密钥。
  2. 尽管经常使用“项目”一词,但我认为这与项目的开源定义有关。不是作为解决方案一部分的视觉工作室定义。
  3. “sonarqube_project_version”究竟是什么意思?我试过 6.5(SonarQube 版本)、6.4.1(SonarQubeC# 插件)、1.0.1(MSBuild.SonarQube.Runner.exe 版本)

我使用了 C# 插件网站上作为示例给出的项目密钥:

MSBuild.SonarQube.Runner.exe 开始 /k:"org.sonarqube:sonarqube-scanner-msbuild" /n:"Kadaster.Agris" /v:"1.0.1"

我在这些问题上尝试了几种排列方式。
我想使用Analysis Bootstrapper for Visual Studio,但找不到下载或说明如何做到这一点。

编辑:在请求后放入整个错误消息。 在文本中,这还包括我在迄今为止给出的答案之后使用的命令:

> D:\projects\agris\src>MSBuild.SonarQube.Runner.exe begin
> /k:"org.sonarqube:Kadas ter_Agris" /n:"Kadaster_Agris" /v:"0.1"
> Default properties file was found at
> D:\Software\MSBuild.SonarQube.Runner.1.0.1\ SonarQube.Analysis.xml
> Loading analysis properties from
> D:\Software\MSBuild.SonarQube.Runner.1.0.1\Sona rQube.Analysis.xml
> Pre-processing started. Preparing working directories... Checking for
> updates... The C# plugin installed on the SonarQube server is not
> compatible with the Sonar Qube analysis agent (i.e. the
> MSBuild.SonarQube.Runner.exe, or the build automat ion task). Either
> check the compatibility matrix or get the latest versions for both.
> Pre-processing failed. Exit code: 1

The first step is to do pre-processing:

> D:\projects\agris\src>D:\Software\sonar-scanner-msbuild-3.0.2.656\MSBuild.SonarQ
> ube.Runner.exe begin /k:"myCompanyHostedSonarQube:GMA_Kadaster_Agris"
> /n:"Kadas ter_Agris" /v:"0.1" SonarQube Scanner for MSBuild 3.0.2
> Default properties file was found at
> D:\Software\sonar-scanner-msbuild-3.0.2.656 \SonarQube.Analysis.xml
> Loading analysis properties from
> D:\Software\sonar-scanner-msbuild-3.0.2.656\Son arQube.Analysis.xml
> Pre-processing started. Preparing working directories... 09:08:16.861 
> Updating build integration targets... 09:08:16.879  Fetching analysis
> configuration settings... 09:08:17.971  Generating rulesets...
> 09:08:17.993  Provisioning analyzer assemblies for cs... 09:08:17.994 
> Installing required Roslyn analyzers... 09:08:18.507  Pre-processing
> succeeded.

那么必须重新构建项目。
然后告诉 SonarQube 结束并将所有内容发送到服务器,这最后一步失败:

> Done Building Project "D:\projects\agris\src\Kadaster.Agris.sln"
> (Rebuild targe t(s)).
> 
> 
> Build succeeded.
> 
> "D:\projects\agris\src\Kadaster.Agris.sln" (Rebuild target) (1) ->
> "D:\projects\agris\src\Kadaster.Agris.Web\Kadaster.Agris.Web.csproj.metaproj"
> ( Rebuild target) (13) ->
> "D:\projects\agris\src\Kadaster.Agris.Web\Kadaster.Agris.Web.csproj"
> (Rebuild t arget) (14) -> (CoreCompile target) ->  
> Controllers\OutputController.cs(48,30): warning CS0168: The variable
> 'ex' is declared but never used
> [D:\projects\agris\src\Kadaster.Agris.Web\Kadaster.Agri s.Web.csproj] 
> Controllers\OutputController.cs(80,30): warning CS0168: The variable
> 'ex' is declared but never used
> [D:\projects\agris\src\Kadaster.Agris.Web\Kadaster.Agri s.Web.csproj] 
> Controllers\OutputController.cs(166,30): warning CS0168: The variable
> 'ex' is  declared but never used
> [D:\projects\agris\src\Kadaster.Agris.Web\Kadaster.Agr is.Web.csproj]
> 
>     3 Warning(s)
>     0 Error(s)
> 
> Time Elapsed 00:00:08.91
> 
> D:\projects\agris\src>D:\Software\sonar-scanner-msbuild-3.0.2.656\MSBuild.SonarQ
> ube.Runner.exe end SonarQube Scanner for MSBuild 3.0.2 Default
> properties file was found at
> D:\Software\sonar-scanner-msbuild-3.0.2.656 \SonarQube.Analysis.xml
> Loading analysis properties from
> D:\Software\sonar-scanner-msbuild-3.0.2.656\Son arQube.Analysis.xml
> Post-processing started. The SonarQube MSBuild integration failed:
> SonarQube was unable to collect the re quired information about your
> projects. Possible causes:
>   1. The project has not been built - the project must be built in between the b egin and end steps
>   2. An unsupported version of MSBuild has been used to build the project. Curre ntly MSBuild 14.0 upwards are supported
>   3. The begin, build or end steps have not all been launched from the same fold er Generation of the sonar-properties file failed. Unable to
> complete SonarQube ana lysis. 14:38:26.197  Creating a summary
> markdown file... 14:38:26.2  Post-processing failed. Exit code: 1

三个警告是关于未使用的异常变量。

【问题讨论】:

  • 您列出了两个 sonarqube 版本,但您是否验证了服务器上安装的 c# 插件的版本是您认为的版本?正确安装 SonarQube 不会自动更新插件。
  • 感谢您的快速回复。如何验证 C# 插件的版本?我从docs.sonarqube.org/display/PLUG/C%23+Plugin 下载了 C# 4.0 插件。通过将 jar 复制到 $SONARQUBE_HOME/extensions/plugins 手动安装它。 (跟随指南docs.sonarqube.org/display/SONAR/Installing+a+Plugin
  • 您可以通过以管理员身份登录并转到 settings..system..update 中心(在 Sonar 5.1 中)来验证您已安装的版本。寻找早期版本的更新中心,它仍然在设置下,但iirc位置有点不同。
  • 谢谢,安装的版本是C# 4.0插件
  • 抱歉,这就是我要建议的全部...我们使用分析引导程序,而不是 msbuild 插件。

标签: c# sonarqube sonarqube5.1 sonarqube-4.5


【解决方案1】:

我需要制作 SonarQube 项目还是“SonarQube_project_key”是指我希望 SonarQube 扫描的 Visual Studio 项目密钥。

/k: 指定的密钥将用作唯一密钥,以在 SonarQube 服务器上标识您的项目。 它可以是任何东西,这完全取决于你。 例如,一个常见的选择是 Visual Studio 中解决方案的名称。

/n: 参数定义要在 SonarQube 上使用的显示名称。

/v: 参数定义了您的分析所代表的项目版本。 SonarQube 的主要目的之一是跟踪所谓的泄漏期中的代码质量变化, 这是自上次发布以来的时间。 版本更改时,泄漏期的指标会重置。 SonarQube 不会假设您的项目的版本, 你自己明确地告诉它。

尽管经常使用“项目”一词,但我认为这与项目的开源定义有关。不是作为解决方案一部分的视觉工作室定义。

SonarQube 文档中的“项目”一词是指 SonarQube 上的表示形式。在 Visual Studio 术语中,它对应于“解决方案”。您通常为每个 Visual Studio 解决方案创建一个 SonarQube 项目。 这是您希望如何看待质量指标的问题。 在 SonarQube 的一个仪表板下聚合所有 Visual Studio 项目的指标通常是有意义的。

我想使用 Visual Studio 的分析引导程序,但找不到下载或说明。

那已经过时了。在撰写本文时,您应该不再需要它了。


您似乎使用的是非常旧版本的 Scanner for MSBuild。 您可以从这里下载最新版本, 试试这个:

https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+MSBuild

但是,请注意,当前版本的 Scanner for MSBuild 需要 MSBuild 版本 14 或更高版本。 这意味着您的项目需要使用 Visual Studio 2015 或更高版本构建。 如果您的项目使用旧版本, 你将不得不迁移它。

【讨论】:

  • 感谢您的回答,这基本上意味着参数与在 SonarQube 上创建的项目相关,而不是对我的源代码的引用。我收到完全相同的错误消息,但我会编辑完整的消息。我认为我的问题是对原始问题的有效补充,并且该版本只是对较新版本的更新。否则人们会认为这是一个重复的问题。
  • @MrFox 看来您使用的是非常过时的 Scanner for MSBuild 版本。从这里下载最新的:docs.sonarqube.org/display/SCAN/…
  • 我的是.jar,你的是.exe。我下载的 SonarQube 软件中的所有内容都是 .jar (所以 java 包而不是 .exe 打包),也许这就是问题所在?我用你的文件夹替换了“sonarqube-6.5/lib/scanner”,它没有帮助。我正在“sonarqube-6.5\bin\windows-x86-64”中以管理员权限启动 StartSonar.bat。
  • @MrFox 您的评论是关于 SonarQube。我的评论是关于 Scanner for MSBuild。我之前评论中链接的页面顶部的下载链接是这样的:github.com/SonarSource/sonar-scanner-msbuild/releases/download/… 它包含SonarQube.Scanner.MSBuild.exe,您需要使用它来扫描您的项目并将分析推送到您的 SonarQube。
  • 我已经配置了扫描仪并使用命令执行它,它说预处理成功,但没有别的。没有分析或输出。将在编辑中详细说明。
猜你喜欢
  • 2017-05-29
  • 2011-01-05
  • 2018-08-07
  • 2022-01-17
  • 2020-01-26
  • 1970-01-01
  • 1970-01-01
  • 2022-11-16
  • 1970-01-01
相关资源
最近更新 更多