我正在尝试在 .NET 项目中从旧的声纳运行器迁移到新的 MsBuild 声纳运行器。
我遇到的最后一个问题是进行 FxCop 分析。如果 Sonar 中的质量配置文件包含任何 FxCop 规则,我会收到以下构建错误:
ERROR: Caused by: The property "sonar.cs.fxcop.assembly" must be set and the project must have been built to execute FxCop rules.
This property can be automatically set by the Analysis Bootstrapper for Visual Studio Projects plugin, see: http://docs.codehaus.org/x/TAA1Dg.
If you wish to skip the analysis of not built projects, set the property "sonar.visualstudio.skipIfNotBuilt".
我搜索了很多,发现了一些具有相同问题的相当古老的主题,但没有一个解决方案有效。
我尝试添加sonar.visualstudio.enable="true"
参数,但随后出现以下错误:
ERROR: Caused by: Do not use the Visual Studio bootstrapper and set the "sonar.modules" property at the same time.
也尝试添加/d:sonar.visualstudio.skipIfNotBuilt="true"
,但没有帮助。
我究竟做错了什么?如何参数化新的 MsBuild 声纳运行器以使 FxCop 分析工作?
这些是我正在执行的命令(我修改了文件名和路径):
1. Sonar runner begin
MSBuild.SonarQube.Runner.exe begin /key:"MyProject" /name:"MyProject"
/version:"1" /d:sonar.host.url="http://mysonarhost/" /d:sonar.jdbc.dialect="mssql"
/d:sonar.jdbc.url="jdbc:jtds:sqlserver://mysonardb" /d:sonar.jdbc.username="sonar-user"
/d:sonar.jdbc.password="sonar-password" /d:sonar.resharper.cs.reportPath="../../../../resharperresults.xml"
/d:sonar.resharper.solutionFile="MySolution.sln"
/d:sonar.visualstudio.testProjectPattern=".*\.(UnitTests|IntegrationTests)"
/d:sonar.exclusions="obj/**" /d:sonar.dotnet.excludeGeneratedCode="true"
/d:sonar.cs.fxcop.fxCopCmdPath="..\Tools\FxCop.v12.0.21005.1\FxCopCmd.exe"
/d:sonar.visualstudio.solution="MySolution.sln" /d:sonar.dotnet.buildConfigurations="Release"
/d:sonar.language="cs" /d:sonar.sourceEncoding="UTF-8"
/d:sonar.cs.opencover.reportsPaths="..\CodeCoverage\MSTest.Coverage.MySolution.UnitTests.xml"
- 构建:
MSBuild.exe targets.msbuild ...
- ReSharper 分析:
inspectcode.exe /o=resharperresults.xml MySolution.sln
- 赛跑者结束:
MSBuild.SonarQube.Runner.exe end