3

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
Pascal Berger
  • 4,262
  • 2
  • 30
  • 54
SandBox
  • 165
  • 2
  • 11
  • Read the message. What are you setting sonar.cs.fxcop.assembly to? http://stackoverflow.com/questions/23822527/how-to-set-fxcop-installation-path-using-sonarqubes-c-sharp-plugin – Levesque Oct 21 '15 at 14:25
  • 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 Oct 21 '15 at 14:31
  • 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 Oct 21 '15 at 14:44

1 Answers1

1

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.

Dinesh Bolkensteyn
  • 2,971
  • 1
  • 17
  • 20
  • We are actually using the latest MSBuild SonarQube Runner.. I have edit my sonar properties.. Still running into the same issue – SandBox Oct 23 '15 at 12:33
  • It doesn't make sense to have a sonar-project.properties when you use the MSBuild SonarQube Runner. Can you provide the logs of the analysis? – Dinesh Bolkensteyn Oct 23 '15 at 15:15
  • Note that the "MSBuild SonarQube Runner" is *not* a SonarQube plugin. It is a separate download than the SonarQube C# 4.2 plugin. – Dinesh Bolkensteyn Oct 23 '15 at 15:16
  • 1
    Thanks ..The issue turned out to be that we were executing the Runner through a powershell wrapper. Once we switched to command prompt with the right switches it worked.. – SandBox Nov 18 '15 at 00:47