当前位置: 动力学知识库 > 问答 > 编程问答 >

msbuild - TeamCity and SonarQube - not able to run FXCop

问题描述:

I have successfully setup TeamCity to integrate with SonarQube and produce basic reports during a build.

However now that I've enabled all the FXCop rules in SonarQube, **it fails to run* with the following message in the TeamCity build log:

Caused by: java.lang.IllegalArgumentException: No FxCop analysis has been performed on this project, whereas it contains cs files: Verify that you are using the latest version of the SonarQube Scanner for MSBuild, and if you do, please report a bug. In the short term, you can disable all FxCop rules from your quality profile to get rid of this error.

The project is setup to build with Visual Studio version Microsoft Visual Studio 2015 in TeamCity.

However the following warning appears in the TeamCity build log, making me think that it's not actually using the Roslyn compiler.

***********************************************************************************

* Use MSBuild 14 to get the best analysis results *

* The use of MSBuild 12 or the sonar-scanner to analyze C# projects is DEPRECATED *

***********************************************************************************

From reading up on the SonarQube scanner for MS Build at http://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+MSBuild it has the following to say

The SonarQube Scanner for MSBuild requires your project to be built with MSBuild 14.0.

MSBuild 14.0 ships both as part of Visual Studio 2015 and as part of the standalone Microsoft Build Tools 2015. While installing Visual Studio on the analysis machine is not mandatory, we recommend doing so in order to benefit from its additional features such as running VSTest or MSTest unit tests, or FxCop analysis.

I also tried changing TeamCity to use the *MSBuild** runner with MSBuild ToolsVersion 14.0 specified and I still get the same behaviour.

So it would appear that Roslyn is being used to compile the project.

I don't know where to go from here. What am I doing wrong?


Versions

  • TeamCity 9.1.4
  • SonarQube 5.6
  • Version 31 of the Sonar runner plugin
  • Build server has MS Build 14.0 tools installed

Full build log details

[09:56:00][Step 10/10] 09:56:00.842 INFO - Sensor org.sonar.plugins.csharp.CSharpSensor (done) | time=4783ms

[09:56:00][Step 10/10] 09:56:00.842 INFO - Sensor org.sonar.plugins.csharp.CSharpFxCopProvider$CSharpFxCopSensor

[09:56:00][Step 10/10] INFO: ------------------------------------------------------------------------

[09:56:00][Step 10/10] INFO: EXECUTION FAILURE

[09:56:00][Step 10/10] INFO: ------------------------------------------------------------------------

[09:56:00][Step 10/10] Total time: 34.494s

[09:56:01][Step 10/10] Final Memory: 7M/109M

[09:56:01][Step 10/10] INFO: ------------------------------------------------------------------------

[09:56:01][Step 10/10] ERROR: Error during Sonar runner execution

[09:56:01][Step 10/10] org.sonar.runner.impl.RunnerException: Unable to execute Sonar

[09:56:01][Step 10/10] at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)

[09:56:01][Step 10/10] at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)

[09:56:01][Step 10/10] at java.security.AccessController.doPrivileged(Native Method)

[09:56:01][Step 10/10] at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)

[09:56:01][Step 10/10] at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)

[09:56:01][Step 10/10] at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)

[09:56:01][Step 10/10] at org.sonar.runner.api.Runner.execute(Runner.java:100)

[09:56:01][Step 10/10] at org.sonar.runner.Main.executeTask(Main.java:70)

[09:56:01][Step 10/10] at org.sonar.runner.Main.execute(Main.java:59)

[09:56:01][Step 10/10] at org.sonar.runner.Main.main(Main.java:53)

[09:56:01][Step 10/10] Caused by: java.lang.IllegalArgumentException: No FxCop analysis has been performed on this project, whereas it contains cs files: Verify that you are using the latest version of the SonarQube Scanner for MSBuild, and if you do, please report a bug. In the short term, you can disable all FxCop rules from your quality profile to get rid of this error.

[09:56:01][Step 10/10] at org.sonar.plugins.fxcop.FxCopConfiguration.checkMandatoryProperties(FxCopConfiguration.java:104)

[09:56:01][Step 10/10] at org.sonar.plugins.fxcop.FxCopConfiguration.checkProperties(FxCopConfiguration.java:95)

[09:56:01][Step 10/10] at org.sonar.plugins.fxcop.FxCopSensor.analyse(FxCopSensor.java:96)

[09:56:01][Step 10/10] at org.sonar.plugins.fxcop.FxCopSensor.analyse(FxCopSensor.java:91)

[09:56:01][Step 10/10] at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58)

[09:56:01][Step 10/10] at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50)

[09:56:01][Step 10/10] at org.sonar.batch.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:83)

[09:56:01][Step 10/10] at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192)

[09:56:01][Step 10/10] at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)

[09:56:01][Step 10/10] at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)

[09:56:01][Step 10/10] at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:241)

[09:56:01][Step 10/10] at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:236)

[09:56:01][Step 10/10] at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:226)

[09:56:01][Step 10/10] at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)

[09:56:01][Step 10/10] at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)

[09:56:01][Step 10/10] at org.sonar.batch.task.ScanTask.execute(ScanTask.java:47)

[09:56:01][Step 10/10] at org.sonar.batch.task.TaskContainer.doAfterStart(TaskContainer.java:86)

[09:56:01][Step 10/10] at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142)

[09:56:01][Step 10/10] at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127)

[09:56:01][Step 10/10] at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:106)

[09:56:01][Step 10/10] at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:119)

[09:56:01][Step 10/10] at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:79)

[09:56:01][Step 10/10] at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)

[09:56:01][Step 10/10] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

[09:56:01][Step 10/10] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

[09:56:01][Step 10/10] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

[09:56:01][Step 10/10] at java.lang.reflect.Method.invoke(Method.java:497)

[09:56:01][Step 10/10] at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)

[09:56:01][Step 10/10] ... 9 more

[09:56:01][Step 10/10] Process exited with code 1

[09:56:01][Step 10/10] Step Run SonarQube (Static code analysis) (SonarQube Runner) failed

网友答案:

I too got same error. After switching to MSBuild.SonarQube.Runner-2.1 this error was no longer seen.

Used SonarQube Scanner for MSBuild: Launch analysis of .Net projects http://docs.sonarqube.org/display/SCAN/Analyzing+Source+Code

分享给朋友:
您可能感兴趣的文章:
随机阅读: