MSBuild.SonarQube.Runner.exe Resharper SonarQubeSetting failing to be set in MSBuild Proj file

353 views
Skip to first unread message

dan.m...@jda.com

unread,
Feb 10, 2016, 1:44:53 AM2/10/16
to SonarQube
I've been trying and trying to use the examples to set the resharper's report settings inside the msbuild project file and it just isn't working. 

If I put the values I need into a SonarQube.Analysis.xml file and add that as part of the 'begin' statement switch then it works fine, but just can't seem to be set in the project file.  

running from command line: 
1) "C:\Software\MSBuild.SonarQube.Runner-1.1\MSBuild.SonarQube.Runner.exe" begin /k:"myKValue" /n:"myNValue" /v:"myVValue" /s:"%CD%\SonarQube.Analysis.xml"
2) a batch file that basically calls the msbuild.exe with a bunch of parameters (see excerpts below) using the proj file excerpts below
3) "C:\Software\MSBuild.SonarQube.Runner-1.1\MSBuild.SonarQube.Runner.exe" end

the %CD%\SonarQube.Analysis.xml file only has the URL/username/password for the SonarQube Server (and the commented out report paths I'm trying to move into the proj files) 

excerpts from proj file 
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="14.0">
...
  <Target Name="SonarAnalysis">
    <Exec Command="@echo $$$ Start Sonar Analysis: %Time%" />
<CallTarget Targets="SetSonarProjectProperties" />
        <CallTarget Targets="BuildStep" />
        <CallTarget Targets="RunTestsWithCodeCoverage" />
<CallTarget Targets="ResharperInspectionStep"/>

... 
  <Target Name="SetSonarProjectProperties">
<ItemGroup>
<SonarQubeSetting Include="SONAR_RUNNER_OPTS">
<Value>-Xmx2048m -Xms512m</Value>
</SonarQubeSetting>
<SonarQubeSetting Include="sonar.resharper.cs.reportPath">
<Value>$(MSBuildProjectDirectory)\resharper-report.xml</Value>
</SonarQubeSetting>
<SonarQubeSetting Include="sonar.exclusions">
<Value>*.xml</Value>
</SonarQubeSetting>
</ItemGroup>
<Message Text="SonarSetting: SONAR_RUNNER_OPTS set!" />
<Message Text="SonarSetting: sonar.resharper.cs.reportPath set! " />
<Message Text="SonarSetting: sonar.exclusions set!" />
  </Target>
..... 

I even tried putting the MSBuild.SonarQube.Runner.exe stages (as new Targets) in the SonarAnalysis Target sequence After the SetSonarProjectProperties Call and setting the DependsOnTargets to the SetSonarProjectProperties as well to ensure it ran first before the runner "begin".  

Logging indicates that the SONAR_RUNNER_OPTS value is being picked up based on these entries: 
... 
SONAR_RUNNER_OPTS is already set. Value: -Xmx2048m -Xms512m
... 
SONAR_RUNNER_OPTS=-Xmx2048m -Xms512m
  
---------
But I keep getting this error stack trace after being told the Execution has failed

  Caused by: java.lang.IllegalStateException: The property "sonar.resharper.cs.reportPath" must be set.
  at org.sonar.plugins.resharper.ReSharperSensor.checkProperty(ReSharperSensor.java:186)
  at org.sonar.plugins.resharper.ReSharperSensor.analyseReportPath(ReSharperSensor.java:104)
  at org.sonar.plugins.resharper.ReSharperSensor.analyse(ReSharperSensor.java:90)
  at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58)

---------------

I've also tried having the ItemGroup outside any Targets just in case having it inside a Target caused a scope issue, but the MSBuild.SonarQube.Integration.targets Example has them being set inside the Target and I see log entries 
...
SetStyleCopAnalysisSettings:
  Setting 'sonar.stylecop.projectFilePath' to 'C:\<pathtoa>\ProjectOfMine.vcxproj''
...
But since I've seen that code actually writing that value out and not actually using those values as I don't have those rules activated on my paramter I can't confirm any of that, but I am hopeful.  And these entries are why I tried putting the Runner.exe in my msbuild.proj file as I was thinking it was possibly a scoping issue of the settings lost when msbuild.exe finished executing.
  
I also don't think that the sonar.exclusions value is being set either as the first project INFO entries before it fails on Resharper report path not being set should have reported the exclusions and how many files were excluded because of set exclusions.

---------------------------------
I'd love some ideas on how to get these properties set that don't require me to have them in the /s: switch of the 'begin' statement as I plan on having this project integrated with Jenkins very soon and would like this all working in the proj file.
Reply all
Reply to author
Forward
0 new messages