SonarQube.Runner与C#插件不兼容

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

The C# plugin installed on the server is not compatible with the MSBuild.SonarQu
be.Runner.exe – either check the compatibility matrix or get the latest versions
for both.
Pre-processing failed. Exit code: 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:

我已经为这个问题添加了一笔赏金,并在此处添加了有关此问题的问题:

>我是否需要制作SonarQube项目或“SonarQube_project_key”是指我希望SonarQube扫描的visual studio项目密钥.
>即使使用了“项目”这个术语,我也认为这与项目的开源定义有关.视觉工作室定义不是解决方案的一部分.
>“sonarqube_project_version”的含义究竟是什么?我试过6.5(SonarQube版本),6.4.1(SonarQubeC#plugin),1.0.1(MSBuild.SonarQube.Runner.exe版本)

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

MSBuild.SonarQube.Runner.exe begin /k:”org.sonarqube:sonarqube-scanner-msbuild” /n:”Kadaster.Agris” /v:”1.0.1″

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

编辑:请求后输入整个错误消息.
《SonarQube.Runner与C#插件不兼容》
在文本中,这还包括我在目前为止给出的答案之后使用的命令:

> 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

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

最佳答案

Do I need to make a SonarQube project or does “SonarQube_project_key” mean the visual studio project key I want SonarQube to scan.

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

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

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

Even though the term ‘project’ is used a lot I assume this relates to the open source definition of project. Not the visual studio definition that’s part of a solution.

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

I would like to use the Analysis Bootstrapper for Visual Studio but can’t find a download or explanation of how that could be done.

这已经过时了.在撰写本文时,您不应再需要它了.

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

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

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

点赞