DanielHWe / sonar-fxcop

FxCop plugin for C# or VB.NET projects
14 stars 6 forks source link

FxCop 1.3 Version is not working with the Sonar Build task version 4.0 #13

Closed JayaPrasad918 closed 6 years ago

JayaPrasad918 commented 6 years ago

Complete Sonarqube analysis task is failing with the below error

ERROR: Error during SonarQube Scanner execution 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. If I am using Sonar build task 4.0 analysis is failing but if i am using 2.0 sonar build task version it is working. Could you please help on this issue

DanielHWe commented 6 years ago

You are missing some parameters for the plugin.

Please ensure you have set "sonar.cs.fxcop.assembly" or "sonar.cs.fxcop.slnFile", "sonar.cs.fxcop.fxCopCmdPath" and "sonar.cs.fxcop.directory" by use of the /d:"key:value" parameter or SonarQube.Analysis.xml and cs.project.

Please see readme.md for more informations about the required and possible parameters and https://docs.sonarqube.org/display/SCAN/Additional+Analysis+Parameters for how to set parameters.

JayaPrasad918 commented 6 years ago

Thank you Daniel, Is there any other way to have the analysis performed without adding the parameters "sonar.cs.fxcop.slnFile", "sonar.cs.fxcop.fxCopCmdPath" and "sonar.cs.fxcop.director because we have multiple build definitions which are using Sonar tasks updating each definition would be difficult.

DanielHWe commented 6 years ago

Sorry in the moment there is no other way, I think it should be possible to change FxCopSensor.execute so it searches for the *.sln file in context.fileSystem() but that is a new feature for the next version.

vival30 commented 6 years ago

Thanks Daniel, (As per my suggestion) If we add this key parameters ("sonar.cs.fxcop.slnFile", "sonar.cs.fxcop.fxCopCmdPath" and "sonar.cs.fxcop.director") in to the SonarQube.Analysis.xml file properties (like sample.sln) Instead of command line input then it'll reduce input parameters in the command line input.

vival30 commented 6 years ago

Hi Daniel, How can i find the reason for the FxCop analysis is moved to Post process step from MSBuild step. Thanks in Advance

DanielHWe commented 6 years ago

You can use the SonarQube.Analysis.xml file for the parameters instead of command line arguments. See https://docs.sonarqube.org/display/SCAN/Additional+Analysis+Parameters In the readme.md I only listed the command line parameters but both ways will work. (I have to extend the readme later on) I not really know why the analysis was moved, that was made and decided by the devlopers maintaining the SonarQube MSBuild Tools. But my speculation is that this was made because the fx cop plugin was originally part of the C# Plugin and as it was split into its own plugin it was moved to the postbuild step.

DanielHWe commented 6 years ago

I will make a new Featrue request for remaining Task.