简体   繁体   中英

SonarQube.Runner not compatible with C# plugin

I am trying to get the following Sonar C# plugin following the instructions here: 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"

when running step 6)a:

MSBuild.SonarQube.Runner.exe begin /k:"sonarqube_project_key" 
/n:"sonarqube_project_name" /v:"sonarqube_project_version"
  • I have tried SonarQube versions 4.5.4 (LTS) and 5.1.1
  • Developer Command Prompt for VS2012
  • I installed java (oracle): jdk-8u51-windows-x64.exe
  • Microsoft (R) Build Engine version 4.0.30319.34209
  • Running on Windows server 2012

Any ideas on how to fix this?

thanks


From MrFox:

I've added a bounty to this question and am adding my questions on this issue here:

  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.
  2. 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.
  3. What exactly is the meaning of "sonarqube_project_version"? I've tried 6.5 (SonarQube version), 6.4.1 (SonarQubeC# plugin), 1.0.1 (MSBuild.SonarQube.Runner.exe version)

I've used the project key that's given as an example on the C# plugin website:

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

I've tried several permutations on these issues.
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.

Edit: putting in the entire error message after request. 控制台的屏幕截图,显示错 In text, this also include the command I'm using after the answers that have been given so far:

> 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.

Then the project must be rebuild.
Then tell SonarQube to end and send everything to the server, this last step fails:

> 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

The three warnings are about unused exception variables.

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

The key specified by /k: will be used as the unique key to identify your project on SonarQube server. It can be anything, and it's really up to you. A common choice for example is the name of the solution in Visual Studio.

The /n: parameter defines the display name to use on SonarQube.

The /v: parameter defines the version of your project that your analysis represents. One of the main purposes of SonarQube is to track the code quality changes in the so-called leak period , which is the time since the last release. The metrics of the leak period reset when the version changes. SonarQube doesn't assume the version of your project, you tell it yourself explicitly.

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.

The term 'project' in SonarQube documentation refers to the representation on SonarQube. In Visual Studio terms, it corresponds to the 'solution'. You typically create one SonarQube project per Visual Studio solution. This is a matter of how you want to look at your quality metrics. It usually makes sense to aggregate the metrics of all Visual Studio projects under one dashboard in SonarQube.

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.

That's obsolete. You should not need that anymore, at the time of this writing.


It seems you're using a very old version of Scanner for MSBuild. You can download the latest version from here, try with this one:

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

However, note that current versions of Scanner for MSBuild require MSBuild version 14 or higher. That implies that your project needs to be built with Visual Studio 2015 or higher. If your project uses an older version, you will have to migrate it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM