3
votes

We are using SonarQube 5.1 and latest MSBuild Sonar Runner C# plugin 4.2 .

While running the analysis with FxCop Rules enabled we Caused by:

java.lang.IllegalArgumentException: 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 pl
ugin, see: http://docs.codehaus.org/x/TAA1Dg. If you wish to skip the analysis of not built projects, set the property 
"sonar.visualstudio.skipIfNotBuilt".

This is the sonar.project.properties :

# Project identification
sonar.projectKey=TestSonar  
sonar.projectVersion=1.0-SNAPSHOT
sonar.projectName=TestSonar


#Core C# Settings
sonar.silverlight.4.mscorlib.location=C:/Program Files (x86)/Reference Assemblies/Microsoft/Framework/Silverlight/v5.0

#UnitTests
sonar.cs.vstest.reportsPaths=TestSonar_UnitTests/*.trx

#CodeCoverage
#sonar.cs.vscoveragexml.reportsPaths = C:\Users\sabharadwaj\Documents\Visual Studio 2013\Projects\TestSonar\TestSonar_UnitTests\VS2013_TestSonar.coveragexml
sonar.cs.opencover.reportPaths=C:\Users\sabharadwaj\Documents\Visual Studio 2013\Projects\TestSonar\TestSonar_UnitTests\VS2013_TestSonar.coveragexml

#FxCop
sonar.cs.fxcop.assembly=C:\Users\sabharadwaj\Documents\Visual Studio 2013\Projects\TestSonar
sonar.cs.fxcop.fxCopCmdPath=C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\FxCop\FxCopCmd.exe
1
Read the message. What are you setting sonar.cs.fxcop.assembly to? stackoverflow.com/questions/23822527/… - Levesque
Have updated the sonar.project.properties to show the FxCop paths.. BUT with or without the FxCop properties I get the same error...fx.cop assembly is set to the path of Solution - SandBox
Sorry, I missed that you had defined those properties because they look like the're comments. There are spaces in your path names, did you try enclosing them in quotations? Are you using the visual studio bootstrapper? Is FxCop actually installed on your system? - Levesque

1 Answers

1
votes

Since the C# plugin version 4.0, the recommended and only supported way of analyzing projects is through the use of the MSBuild SonarQube Runner, developed jointly with Microsoft. See the documentation http://redirect.sonarsource.com/plugins/csharp.html

This new way of analyzing C# projects fully integrates with MSBuild, and solves many integration issues such as the one you are currently facing.

The Analysis Bootstrapper Plugin for Visual Studio Projects Plugin (aka the Visual Studio Bootstrapper Plugin) that you are trying to enable with sonar.visualstudio.enable has been deprecated, and might not be installed on your SonarQube server. If it's there, you'll be able to safely uninstall it after you've migrated all your projects to use the MSBuild SonarQube Runner. You also will be able to delete the sonar-project.properties file of migrated projects.