簡體   English   中英

SonarQube.Runner與C#插件不兼容

[英]SonarQube.Runner not compatible with C# plugin

我試圖按照這里的說明獲取以下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#plugin),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“

我在這些問題上嘗試了幾種排列方式。
我想使用Visual StudioAnalysis Bootstrapper,但無法找到如何完成的下載或解釋。

編輯:請求后輸入整個錯誤消息。 控制台的屏幕截圖,顯示錯 在文本中,這還包括我在目前為止給出的答案之后使用的命令:

> 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項目或“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的Analysis Bootstrapper,但無法找到如何完成的下載或解釋。

這已經過時了。 在撰寫本文時,您不應再需要它了。


您似乎正在使用非常舊版本的Scanner for MSBuild。 您可以從這里下載最新版本,試試這個:

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

但請注意,當前版本的Scanner for MSBuild需要MSBuild版本14或更高版本。 這意味着您的項目需要使用Visual Studio 2015或更高版本構建。 如果您的項目使用的是舊版本,則必須進行遷移。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM