1、下载解压sonarqube,双击运行StartSonar
注:必须安装java,且版本高于11
2、浏览器访问:http://localhost:9000/,点击Login,默认管理员账号和密码都是 admin,进入到 Sonar 的项目管理界面。
3、 安装 dotnet scanner
dotnet tool install --global dotnet-sonarscanner
4、分析项目
跳转到你需要分析的项目的根目录。
在命令行工具当中分步执行以下命令:
dotnet sonarscanner begin /k:"iLearning" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="ee3602c8cfb60b2841bcf62fac9d7645cddf0507"
dotnet build
dotnet sonarscanner end /d:sonar.login="ee3602c8cfb60b2841bcf62fac9d7645cddf0507"
WARNING: The following projects do not have a valid ProjectGuid and were not built using a valid solution (.sln) thus will be skipped from analysis…
No analysable projects were found. SonarQube analysis will not be performed. Check the build summary report for details.
Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
16:09:26.217 Post-processing failed. Exit code: 1
dotnet new sln
The SonarQube MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
Possible causes:
- The project has not been built - the project must be built in between the begin and end steps
- An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0.25420.1 and higher are supported.
- The begin, build and end steps have not all been launched from the same folder
- None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
dotnet msbuild -verison
16.3.0.46305
dotnet sln TestConsoleApp.sln add TestConsoleApp.csproj