I am trying to migrate from the old Sonar runner to the new MsBuild Sonar runner in a .NET project.
The last problem I have is doing the FxCop analysis. If the quality profile in Sonar contains any FxCop rules, I get the following build error:
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".
I googled a lot and found some rather old topics with the same problem, but none of the solutions worked.
I tried to add the sonar.visualstudio.enable="true"
parameter, but then I get the following error:
ERROR: Caused by: Do not use the Visual Studio bootstrapper and set the "sonar.modules" property at the same time.
Also tried to add /d:sonar.visualstudio.skipIfNotBuilt="true"
, but it didn't help.
What am I doing wrong? How to parameterize the new MsBuild sonar runner to make the FxCop analysis work?
These are the commands I'm executing (I modified the file names an paths):
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:
MSBuild.exe targets.msbuild ...
- ReSharper analysis:
inspectcode.exe /o=resharperresults.xml MySolution.sln
- Runner end:
MSBuild.SonarQube.Runner.exe end