问题
I'm trying to analyze .NET C# project using SonarQube C# plugin. From C# Plugin 3.0, FxCop is automatically executed even thogh "sonar.fxcop.mode=skip" in sonar-project.properties, so I installed FxCop to following directory.
C:\Program Files (x86)\Microsoft FxCop 1.35
When I ran SonarQube Runner from Jenkins's sonar plugin, then I got following error.
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: The property "sonar.cs.fxcop.assembly" must be set.
ERROR:
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
Build step 'Invoke Standalone Sonar Analysis' marked build as failure
Finished: FAILUR
I enabled Visual Studio Bootstrapper on SonarQube, and I ran SonarQube Runner again, then I got following error.
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: java.io.IOException: Cannot run program "C:/Program Files (x86)/Microsoft Visual Studio 12.0/Team Tools/Static Analysis Tools/FxCop/FxCopCmd.exe": CreateProcess error=2, ?w?????t?@?
ERROR: Caused by: Cannot run program "C:/Program Files (x86)/Microsoft Visual Studio 12.0/Team Tools/Static Analysis Tools/FxCop/FxCopCmd.exe": CreateProcess error=2, ?w?????t?@?
ERROR: Caused by: CreateProcess error=2, ?w?????t?@?
ERROR:
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
I add "sonar.fxcop.installDirector=C:/Program Files (x86)/Microsoft FxCop 1.35" to sonar-project.properties, and ran SonarQube Runner again however same error occured.
I guess if Visual Studio Bootstrapper disabled and sonar-project.properties specify "sonar.cs.fxcop.assembly" and "sonar.fxcop.installDirector" correctly, It's work fine, but I don't want to specify many properties in sonar-project.properties.
How can I set FxCop execution path with enabling Visual Studio Bootstrapper?
Environment:
- SonarQube4.2
- SonarQube's C# plugin 3.0
- SonarQube Runner 2.4
sonar-project.properties
sonar.projectKey=xxxxx
sonar.projectVersion=1.0
sonar.projectName=Project Name
sonar.language=cs
sonar.dotnet.key.generation.strategy=safe
sonar.sourceEncoding=UTF-8
# This property is set because it is required by the SonarQube Runner.
# But it is not taken into account because the location of the source
# code is retrieved from the .sln and .csproj files.
sonar.sources=.
sonar.fxcop.mode=skip
sonar.gendarme.mode=skip
sonar.gallio.mode=skip
sonar.ndeps.mode=skip
sonar.stylecop.mode=skip
sonar.fxcop.installDirector=C:/Program Files (x86)/Microsoft FxCop 1.35
Regards
回答1:
I found the solution for this issue , Login as an administration on sonar qube and then go to setting , under general setting you find Category, select C# then Click on Code Analysis/FxCop tab , then find "Path to FxCopCMD.Exe" and add the full path of FXCopCMD.exe as suggested in example
click on this to see image and process
回答2:
Same problem here. I think after you installed Visual Studio Bootstrapper you'll need to setup the following key to match the path to FxCop executable:
sonar.cs.fxcop.fxCopCmdPath
which by default has the value you mentioned in the second error log.
来源:https://stackoverflow.com/questions/23822527/how-to-set-fxcop-installation-path-using-sonarqubes-c-sharp-plugin