【发布时间】:2015-11-15 12:38:47
【问题描述】:
我正在尝试在 .NET 项目中从旧的 Sonar 运行器迁移到新的 MsBuild Sonar 运行器。
我遇到的最后一个问题是进行 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 开始
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:
MSBuild.exe targets.msbuild ...
- ReSharper 分析:
inspectcode.exe /o=resharperresults.xml MySolution.sln
- 赛跑者终点:
MSBuild.SonarQube.Runner.exe end
【问题讨论】:
-
或者使用新的跑步者,FxCop 报告必须手动生成,类似于 ReSharper 报告?
-
不,FxCop 应该在 MSBuild 期间强制执行 - 也就是说,除非您对 .csproj 和 MSBuild 文件进行了大量自定义 - 是这样吗?
-
您可以删除未使用的属性:sonar.cs.fxcop.fxCopCmdPath, sonar.visualstudio.solution, sonar.visualstudio.testProjectPattern
-
也许尝试做一个完整的 MSBuild 重建,并发送日志
标签: msbuild sonarqube fxcop sonar-runner sonarqube-msbuild-runner