简体   繁体   中英

Generation of the sonar-properties file failed. Unable to complete SonarQube analysis

Application Stack

  • Jenkins
  • .NET 4.7
  • SonarQube 7.4
  • Bitbucket (Source control)
  • VS 2015 Update 3
  • VsTest to execute UnitTest

Path of Msbuid in Global Tools Configuration is

  1. C:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\Msbuild.exe
  2. Also tried with C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\Msbuild.exe

We have created sample project and configured all in one server.

We can see multiple kind of errors in log files like

  • Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
  • WARNING: File 'C:\\Program Files (x86)\\Jenkins\\workspace\\CICD\\UnitTestProject1\\Properties\\AssemblyInfo.cs' is not located under the root directory 'C:\\Program Files (x86)\\Jenkins\\workspace\\CICD.sonarqube\\out' and will not be analyzed
  • No analysable projects were found. SonarQube analysis will not be performed
  • This only comes when i use msbuild from "Program files" An instance of analyzer SonarAnalyzer.Rules.CSharp.FieldsShouldNotBePublic cannot be created from C:\\Users\\manish.joisar\\AppData\\Local\\Temp.sonarqube\\resources\\0\\SonarAnalyzer.CSharp.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=1.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies

I can see message with build succeeded.

I can also see successful test run message Total tests: 1. Passed: 1. Failed: 0. Skipped: 0. Test Run Successful.

Sonar configuration is done in build configuration under "Execute Sonar scanner" step

I am not sure what is missing here, wrong configuration, wrong msbuild ??

I suppose you have gone through this documentation https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+MSBuild for getting all the dependencies information and the command required to run the analysis.

I was getting some of the error mentioned above when i was trying to analyse c# files but i require more information to understand your case so please provide the o/p of each steps mentioned below:

SonarScanner.MSBuild.exe begin /k:"project-key"
MSBuild.exe <path to solution.sln> /t:Rebuild
SonarScanner.MSBuild.exe end

If you are running through jenkins MSBuild plugin, then please provide the verbose output of the same.

I solved all above issues with below configuration in Jenkins

SonarQube configuration 在此处输入图片说明

Jenkin Global tool configuration 在此处输入图片说明

Freestyle project configuration在此处输入图片说明

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