Maven + .NET + Sonar v4.5.1 + Analysis Bootstrapper for Visu

本文关键字:Analysis Bootstrapper Visu for NET Sonar v4 Maven | 更新日期: 2023-09-27 18:35:13

我正在尝试使用 Maven 3.2.3 为 .NET C# 项目运行 sonar(v 4.5.1) 构建。我面临以下错误,并在这里遇到这种情况,无法继续。

错误日志:

[INFO] [13:06:21.552] The import of some StyleCop issues were skipped. See DEBUG logs for details.
[INFO] [13:06:21.553] Sensor org.sonar.plugins.stylecop.StyleCopSensor@19bcfc1 done: 11995 ms
[INFO] [13:06:21.555] Sensor JMeterSensor...
[INFO] [13:06:21.555] Sensor JMeterSensor done: 0 ms
[INFO] [13:06:21.555] Sensor org.sonar.plugins.csharp.squid.CSharpSquidSensor@58aa13...
[INFO] [13:06:21.607] 53 source files to be analyzed
[INFO] [13:06:22.291] 53/53 source files analyzed
[INFO] [13:06:22.352] Sensor org.sonar.plugins.csharp.squid.CSharpSquidSensor@58aa13 done: 797 ms
[INFO] [13:06:22.352] Sensor org.sonar.plugins.csharp.core.CSharpFxCopProvider$CSharpFxCopSensor@1060218...
[DEBUG] [13:06:22.354] Release semaphore on project : org.sonar.api.resources.Project@1c60683[id=10140,key=OrgName:ProjectName,qualifier=TRK], with key batch-OrgName:ProjectName
[ERROR] 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 plugin, see: http://docs.codehaus.org/x/TAA1Dg.If you wish to skip the analysis of not built projects, set the property "sonar.visualstudio.skipIfNotBuilt".
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:16 min
[INFO] Finished at: 2014-12-23T13:06:22-08:00
[INFO] Final Memory: 17M/130M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.sonar:sonar-maven-plugin:4.5.1:sonar (default-cli) on project OrgName:ProjectName: 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 plugin, see: http://docs.codehaus.org/x/TAA1Dg.If you wish to skip the analysis of not built projects, set the property "sonar.visualstudio.skipIfNotBuilt". -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.sonar:sonar-maven-plugin:4.5.1:sonar (default-cli) on project OrgName-ProjectName: 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 plugin, see: http://docs.codehaus.org/x/TAA1Dg.If you wish to skip the analysis of not built projects, set the property "sonar.visualstudio.skipIfNotBuilt".
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: 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 plugin, see: http://docs.codehaus.org/x/TAA1Dg. If you wish to skip the analysis of not built projects, set the property "sonar.visualstudio.skipIfNotBuilt".
        at org.sonar.maven.ExceptionHandling.handle(ExceptionHandling.java:37)
        at org.sonar.maven.SonarMojo.execute(SonarMojo.java:175)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        ... 19 more
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 plugin, see: http://docs.codehaus.org/x/TAA1Dg. If you wish to skip the analysis of not built projects, set the property "sonar.visualstudio.skipIfNotBuilt".
        at org.sonar.plugins.fxcop.FxCopConfiguration.checkMandatoryProperties(FxCopConfiguration.java:94)
        at org.sonar.plugins.fxcop.FxCopConfiguration.checkProperties(FxCopConfiguration.java:86)
        at org.sonar.plugins.fxcop.FxCopSensor.analyse(FxCopSensor.java:91)
        at org.sonar.plugins.fxcop.FxCopSensor.analyse(FxCopSensor.java:86)
        at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:79)
        at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:70)
        at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:119)
        at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:194)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
        at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:233)
        at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:228)
        at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:226)
        at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:221)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
        at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:64)
        at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:51)
        at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:125)
        at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
        at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
        at org.sonar.batch.bootstrap.BootstrapContainer.executeTask(BootstrapContainer.java:173)
        at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
        at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
        at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
        at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
        at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
        at org.sonar.runner.api.Runner.execute(Runner.java:100)
        at org.sonar.maven.SonarMojo.execute(SonarMojo.java:173)
        ... 21 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

当我将属性设置为

sonar.visualstudio.skipIfNotBuilt=true

我得到这样的错误。

[ERROR] No Visual Studio projects were found.

我的pom.xml配置是,

    <sonar.visualstudio.enable>true</sonar.visualstudio.enable>
    <sonar.dotnet.visualstudio.solution.file>projetName.sln</sonar.dotnet.visualstudio.solution.file>
    <visual.test.project.pattern>*.Tests</visual.test.project.pattern>
    <dotnet.tool.version>4.5</dotnet.tool.version>
    <sonar.language>cs</sonar.language>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <sonar.cs.fxcop.fxCopCmdPath><program_files>/Fxcop/FxCopCmd.exe</sonar.cs.fxcop.fxCopCmdPath>
    <sonar.stylecop.msBuildPath>C:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe</sonar.stylecop.msBuildPath>
    <sonar.stylecop.styleCopDllPath><program_files>/StyleCop 4.7/StyleCop.dll</sonar.stylecop.styleCopDllPath>
    <sonar.fxcop.installDirectory><program_files>/Fxcop</sonar.fxcop.installDirectory>  

请向我建议一个解决方案。

Maven + .NET + Sonar v4.5.1 + Analysis Bootstrapper for Visu

我终于解决了为所有子模块输入 fxcop 程序集的问题。

sonar.cs.fxcop.assembly=subproject1/bin/Debug/subproject1.dll
sonar.cs.fxcop.assembly=subproject2/bin/Debug/subproject2.dll  
sonar.cs.fxcop.assembly=subproject3/bin/subproject3.dll

我会尝试设置以下属性之一。 我不确定您正在构建什么类型的应用程序,但是如果不将fxcop目录属性设置为我的lib文件夹或bin输出文件夹,我就无法让我的MVC项目通过此步骤。

sonar.cs.fxcop.directories=
sonar.visualstudio.outputPaths=

并将 Visual Studio 解决方案属性更改为以下内容

sonar.visualstudio.solution=projetName.sln

http://docs.sonarqube.org/display/SONAR/Analysis+Bootstrapper+for+Visual+Studio+Projects+Plugin