0

I am trying to analyse my solution (C# .NET) using sonar. Unfortunately after plugins loading it is failing with following stacktrace:

14:53:19.646 DEBUG - Release semaphore on project : org.sonar.api.resources.Project@7f9b2bab[id=3169,key=com.exigenservices:cm,qualifier=TRK], with key batch-com.exigenservices:cm
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 2:12.629s
Final Memory: 13M/405M
ERROR: Error during Sonar runner execution
INFO: ------------------------------------------------------------------------
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
   at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
   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:90)
   at org.sonar.runner.Main.executeTask(Main.java:70)
   at org.sonar.runner.Main.execute(Main.java:59)
   at org.sonar.runner.Main.main(Main.java:41)
Caused by: java.util.NoSuchElementException
   at java.util.HashMap$HashIterator.nextEntry(HashMap.java:929)
   at java.util.HashMap$ValueIterator.next(HashMap.java:954)
   at org.sonar.dotnet.tools.commons.visualstudio.VisualStudioProject.getArtifactDirectory(VisualStudioProject.java:178)
   at org.sonar.dotnet.tools.commons.visualstudio.VisualStudioProject.getArtifact(VisualStudioProject.java:195)
   at org.sonar.dotnet.tools.commons.visualstudio.VisualStudioProject.getGeneratedAssemblies(VisualStudioProject.java:209)
   at org.sonar.plugins.csharp.api.sensor.AbstractRegularCSharpSensor.assembliesFound(AbstractRegularCSharpSensor.java:101)
   at org.sonar.plugins.csharp.api.sensor.AbstractRegularCSharpSensor.shouldExecuteOnProject(AbstractRegularCSharpSensor.java:81)
   at org.sonar.plugins.csharp.api.sensor.AbstractRuleBasedCSharpSensor.shouldExecuteOnProject(AbstractRuleBasedCSharpSensor.java:48)
   at org.sonar.batch.bootstrap.BatchExtensionDictionnary.shouldKeep(BatchExtensionDictionnary.java:62)
   at org.sonar.batch.bootstrap.BatchExtensionDictionnary.getFilteredExtensions(BatchExtensionDictionnary.java:52)
   at org.sonar.batch.bootstrap.BatchExtensionDictionnary.select(BatchExtensionDictionnary.java:42)
   at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:63)
   at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:114)
   at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:150)

Actually in sonar cache (.sonar) directory presented following plugins:

checkstyle
core
cpd
csharp
csharpfxcop
csharpgallio
csharpgendarme
csharpndeps
csharpsquid
csharpstylecop
dbcleaner
design
emailnotifications
findbugs
jacoco
java
l10nen
mavenbatch
pmd
squidjava
surefire

Unfortunately I have not any idea hot to fix it and where is an issue due poorness of sonar debug messages.

Alex G.P.
  • 9,609
  • 6
  • 46
  • 81

2 Answers2

1

The Visual Studio project parser in SonarQube's .Net plugins expect to find the output files using this xpath:

"/vst:Project/vst:PropertyGroup[contains(@Condition,'" + config + "')]/vst:OutputPath"

where config is the build configuration it has determined it should use.

From what I can tell looking at the current source code and the exception stack trace you provided (which don't line up exactly), the exception is getting thrown on this line:

  if (artifactDirectory == null) {
    // just take the first one found...
    artifactDirectory = buildConfOutputDirMap.values().iterator().next();

which implies that it couldn't find any build output for your project.

If you find that your csproj file has a different location for the OutputPath, please submit a bug report to the SonarQube user mailing list so that it can be fixed in the future.

John M. Wright
  • 4,477
  • 1
  • 43
  • 61
0

This means that the CSPROJ file of your project is not correct and is missing some information about the artifact directory where the assembly is generated.

  • Thank you for hint, but maybe you can explain which xpath (and in which namespace) sonar is expecting from `csproj` file? I am trying to figure out where is the issue. My project file has OutputPath, has XML header, has root element looks like ``. Also it has `OutputPath` inside `PropertyGroup` with condition `Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "`. – Alex G.P. Nov 18 '13 at 08:54
  • Can you edit your question and copy-paste the beginning of your CSPROJ file? (where all the properties are listed) – Fabrice - SonarSource Team Nov 18 '13 at 12:56