我已成功设置 TeamCity 以与 SonarQube 集成,并在构建期间生成基本报告。
但是现在我已经在SonarQube中启用了所有FXCop规则,**它无法在TeamCity构建日志中运行*并显示以下消息:
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.
该项目设置为使用TeamCity中的Visual Studio版本Microsoft Visual Studio 2015
进行构建。
但是,TeamCity构建日志中出现了以下警告,这让我觉得它实际上并没有使用Roslyn编译器。
***********************************************************************************
* Use MSBuild 14 to get the best analysis results *
* The use of MSBuild 12 or the sonar-scanner to analyze C# projects is DEPRECATED *
***********************************************************************************
通过在http://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+MSBuild上阅读SonarQube扫描仪进行MS Build,它有以下说法
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.
我还尝试将TeamCity更改为使用指定了MSBuild ToolsVersion 14.0的* MSBuild **运行程序,我仍然得到相同的行为。
因此,似乎使用Roslyn 来编译项目。
我不知道从哪里开始。我做错了什么?
版本
完整构建日志详细信息
[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
答案 0 :(得分:0)
我也有同样的错误。切换到 MSBuild.SonarQube.Runner-2.1 后,再也看不到此错误。
用于MSBuild的SonarQube扫描仪:启动.Net项目分析 http://docs.sonarqube.org/display/SCAN/Analyzing+Source+Code