运行sonar-runner时从解决方案中排除项目

时间:2013-10-03 15:05:42

标签: c# sonarqube sonar-runner

我已经安装并配置了SonarQube 3.7.1和sonar-runner 2.3。

在尝试在c#解决方案上运行sonar-runner时,我收到了错误:

ERROR: Error during Sonar runner execution 
ERROR: Unable to execute Sonar 
ERROR: Caused by: Error occured while reading Visual Studio files. 
ERROR: Caused by: Error while processing the project C:\root\MPS\MPA\Main\Source\MPA.Build\MPA.Build.csproj : assemblyName not defined

我的sonar-project.properties看起来像

sonar.projectKey=CompanyName:MPA.Android 
sonar.projectName=MPA
sonar.projectVersion=1.0

sonar.sources=. 
sonar.language=cs
sonar.sourceEncoding=UTF-8
\#sonar.dotnet.key.generation.strategy=safe
sonar.dotnet.visualstudio.solution.file=MPA.sln

sonar.skippedModules=MPA.Build

我想排除项目MPA.Build。但它没有用。

在MPA.sln文件中,MPA.Build项目定义为

  

项目(" {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}")=" MPA.Build"," MPA.Build \ MPA.Build.csproj& #34;," {A8B400F6-A5C5-4843-96CA-92B25A2E6483}"   EndProject

任何人都知道如何解决此错误?

当运行sonar-runner -X时输出为:

  

错误:Sonar跑步者执行期间出错   org.sonar.runner.impl.RunnerException:无法执行Sonar           在org.sonar.runner.impl.BatchLauncher $ 1.delegateExecution(BatchLauncher.java:91)           在org.sonar.runner.impl.BatchLauncher $ 1.run(BatchLauncher.java:75)           at java.security.AccessController.doPrivileged(Native Method)           在org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)           在org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)           在org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)           在org.sonar.runner.api.Runner.execute(Runner.java:90)           在org.sonar.runner.Main.executeTask(Main.java:70)           在org.sonar.runner.Main.execute(Main.java:59)           at org.sonar.runner.Main.main(Main.java:41)引起:org.sonar.api.utils.SonarException:读取Visual时出错   Studio文件。           在org.sonar.plugins.dotnet.core.VisualStudioProjectBuilder.createVisualStudioSolution(VisualStudioProjectBuilder.java:190)           在org.sonar.plugins.dotnet.core.VisualStudioProjectBuilder.build(VisualStudioProjectBuilder.java:82)           在org.sonar.api.batch.bootstrap.ProjectBuilder.build(ProjectBuilder.java:67)           在org.sonar.batch.scan.ProjectReactorReady.start(ProjectReactorReady.java:63)           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)           在java.lang.reflect.Method.invoke(Method.java:597)           在org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110)           在org.picocontainer.lifecycle.ReflectionLifecycleStrategy.start(ReflectionLifecycleStrategy.java:89)           at org.picocontainer.injectors.AbstractInjectionFactory $ LifecycleAdapter.start(AbstractInjectionFactory.java:84)           at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169)           在org.picocontainer.behaviors.Stored $ RealComponentLifecycle.start(Stored.java:132)           在org.picocontainer.behaviors.Stored.start(Stored.java:110)           在org.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1015)           at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1008)           在org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:766)           at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:91)           在org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)           在org.sonar.batch.scan.ScanTask.scan(ScanTask.java:57)           在org.sonar.batch.scan.ScanTask.execute(ScanTask.java:45)           在org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:82)           在org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)           在org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)           在org.sonar.batch.bootstrap.BootstrapContainer.executeTask(BootstrapContainer.java:156)           在org.sonar.batch.bootstrap.BootstrapContainer.doAfterStart(BootstrapContainer.java:144)           在org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)           在org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)           在org.sonar.batch.bootstrapper.Batch.startBatch(Batch.java:92)           在org.sonar.batch.bootstrapper.Batch.execute(Batch.java:74)           在org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:45)           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)           在java.lang.reflect.Method.invoke(Method.java:597)           在org.sonar.runner.impl.BatchLauncher $ 1.delegateExecution(BatchLauncher.java:87)           ... 9更多引起:org.sonar.plugins.dotnet.api.DotNetException:处理时出错   项目C:\ root \ MPS \ MPA \ Main \ Source \ MPA.Build \ MPA.Build.csproj:   assemblyName未定义           在org.sonar.plugins.dotnet.api.microsoft.ModelFactory.getProject(ModelFactory.java:364)           at org.sonar.plugins.dotnet.api.microsoft.ModelFactory.getProjects(ModelFactory.java:274)           在org.sonar.plugins.dotnet.api.microsoft.ModelFactory.getSolution(ModelFactory.java:198)           在org.sonar.plugins.dotnet.core.VisualStudioProjectBuilder.createVisualStudioSolution(VisualStudioProjectBuilder.java:185)           ... 44更多

3 个答案:

答案 0 :(得分:1)

“assemblyName not defined”=>您只需要修复不正确的MPA.Build.csproj文件,因为缺少标签“AssemblyName”。例如,请参阅https://github.com/SonarSource/sonar-examples/blob/master/projects/languages/csharp/Example.Core/Example.Core.csproj

答案 1 :(得分:0)

您拥有的属性文件语法似乎是正确的。当你运行声纳 - 跑步者时,你应该看到这样的线接近跑步的开头:

INFO  - Apply project exclusions 
INFO  - Exclude project: MPA.Build [SomePrefix:MPA.Build]

如果你不这样做,我建议使用-X参数运行sonar-runner,它会将调试语句打印到控制台。 (您可能希望将控制台重定向/捕获到日志文件。)这可能会提供一些其他信息,以帮助理解为什么它没有看到您的排除。

此外,在SonarQube Web UI中,在查看项目时,单击左侧导航栏中的“组件”链接。这将列出解决方案的“模型”。仔细检查此视图中显示的名称是否与MBA.Build匹配。

答案 2 :(得分:0)

今天我和sonarqube 5.0面对同样的问题。 我尝试了“sonar.skippedModules”,但现在已弃用。

相反,您必须使用visual studio bootstraper提供的以下表达式:

sonar.visualstudio.skippedProjectPattern =