c# 代码进行 sonarscan-msbuild扫描

一、下载soanrscan-msbuild工具,选择一个合适的版本
https://github.com/SonarSource/sonar-scanner-msbuild/releases

二、SonarQube.Analysis.xml配置
数据库的配置可以查看sonarqube的安装文件

<SonarQubeAnalysisProperties  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.sonarsource.com/msbuild/integration/2015/1">
  <Property Name="sonar.host.url">http://192.168.xx.xx:9000/Property>
  <Property Name="sonar.login">xxxxxxxxProperty>
  <Property Name="sonar.password">Property>
  
  
  <Property Name="sonar.jdbc.url">jdbc:mysql://192.168.xx.xx:3306/sonarqube?useUnicode=trueProperty>
  <Property Name="sonar.jdbc.username">xxxProperty>
  <Property Name="sonar.jdbc.password">xxxProperty>
SonarQubeAnalysisProperties>

三,执行编译之前需要在soanrqube上创建相应的项目static_check_psj_c_sharp_msbuild

E:\program\sonar-scanner-msbuild-4.3.1.1372-net46\SonarScanner.MSBuild.exe begin /k:"static_check_psj_c_sharp_msbuild" /d:sonar.host.url="http://192.168.xx.xx:9000" /d:sonar.login="xxxx" /v:"1"
C:\"Program Files (x86)"\"Microsoft Visual Studio"\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe xxxx.sln  /t:Rebuild
E:\program\sonar-scanner-msbuild-4.3.1.1372-net46\SonarScanner.MSBuild.exe end /d:sonar.login="xxxx"

在执行的过程中,报错,显示需要14.0或者14.0的msbuild,由于vs2019是16.0的,所以需要单独安装14.0

四,单独安装msbuild15.0
参考:https://stackoverflow.com/questions/52729944/how-to-get-msbuild-15-without-a-full-install-of-visual-studio

https://my.visualstudio.com/Downloads?q=visual%20studio%202017&wt.mc_id=omsftvscom~older-downloads
可以单独安装msbuild 15.0,需要注册一个微软账号.

你可能感兴趣的:(jenkins持续集成)