Source Code Analysis For Xamarin Project With SonarQube On Mac. RRS feed

  • Question

  • User272231 posted

    Hi All,

    Please find the below steps to implement sonarqube analysis for your Xamarin Project .

    Requirements & Installation Steps :

    1. MSBuild : MSbuild will be installed along with Mono already in your machine to verify, Please execute the below command in terminal
            * which msbuild
            * /Library/Frameworks/Mono.framework/Versions/Current/Commands/msbuild
    2. Install Brew (You might have it already).
            * ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
            * To Check installation Open Terminal and Run "brew update"
    3. Install Sonar : 
            * brew install sonar
            * brew install sonar-scanner
    3. Run Sonar In Terminal:
            "Sonar Console" :smile:  
    4. Login To Sonar In Local Machine:
            Open Browser and enter "http://localhost:9000"
            Login as admin, Password- admin
    5. MSbuild for SonarQube : 
            * As of today, the latest version 3.0.2 was not support to Mac OS,  Killed my days
            * The SonarQube version should be > 4.0 +, ********In order to run on NON WINDOW OS Platform. ******** Found the answer in the below link
            * The latest release and download the plugin from - > https://docs.sonarqube.org/pages/viewpage.action?pageId=6954799 [Edited later]
            * Have it in your preferred location.
        6. SonarC#.
            * One more Compatibility issue, The sonarQube 6.7 has the sonarC# Plugin 6.6 in administration -> marketplace, which was having issue in scanning C# code from mac. (Killed My Day Again)
            * If the version was updated by the time you read this, Please use that. You can find the official release version in.
            * SonarC# Plugin Download
            * Add SonarC# Plugin: 6.7 (This can be added manually to the Sonar Plugin folder)
                                  * Open in finder /usr/local/Cellar/sonarqube/6.7/libexec/extensions/plugins
                  * Paste the plugin
                  * Restart sonar in terminal -> sonar restart
    7. Create a Login Token In Sonar.
            * Go to sonar portal in local machine -> http://localhost:9000/
            * Login
            * Go to administration -> Security -> create new token-> Copy the token.
    8. Analyse Source Code.
            * Go the source code root folder, the folder that has the project file that you want to build.
            * Run the below commands
            1. mono /<PATH TO THE MSBUILD_FOR_SONAR_LOCATION>/sonar-scanner-msbuild- begin /k:"COM.YOGI.AWESOME.APP" /n:"APP NAME" /v:"1.0" /d:sonar.login="TOKEN THAT YOU HAVE COPIED IN STEP 8"
                        2. MSbuild /t:rebuild
            3. mono /<PATH TO THE MSBUILD_FOR_SONAR_LOCATION>//sonar-scanner-msbuild- end 
         9. Once Success You can find the report in Sonar.
    10. Login to SonarQube as in Step  4. Report should be available


    Friday, December 8, 2017 4:47 PM

All replies

  • User163359 posted

    I followed your setup steps but still SonarQube does not detect any code issues.

    Wednesday, December 20, 2017 8:23 AM
  • User272231 posted

    Could you please share the error that you are getting, that would be easy to analyze the cause.

    Tuesday, December 26, 2017 9:23 PM
  • User163359 posted

    Actually I get no error but two warnings. I described my problem with more details here:


    Wednesday, January 31, 2018 10:22 AM
  • User380675 posted

    I always get below error after appending the PATH. How to resolve this issue, i am getting this error in my mac OS

    MANOJs-MacBook-Air:sonar-scanner-msbuild- manojdeshpande$ echo $PATH /Library/Frameworks/Mono.framework/Commands/:/anaconda3/bin:/Users/manojdeshpande/miniconda3/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin MANOJs-MacBook-Air:sonar-scanner-msbuild- manojdeshpande$ export PATH=$PATH:/Users/manojdeshpande/Downloads/sonar-scanner-msbuild- MANOJs-MacBook-Air:sonar-scanner-msbuild- manojdeshpande$ SonarScanner.MSBuild.exe -bash: /Users/manojdeshpande/Downloads/sonar-scanner-msbuild- cannot execute binary file

    Sunday, December 16, 2018 2:09 PM
  • User220163 posted

    When i execute the last command, i get below error: mono /MSBuild.SonarQube.Runner.exe end /d:sonar.login="token"

    ERROR: Error during SonarQube Scanner execution ERROR: Line 736 is out of range for file /.cs. File has 735 lines. ERROR: The SonarQube Scanner did not complete successfully 14:18:57.767 Post-processing failed. Exit code: 1

    Can you help on this.

    Below are the version details: SonarQube: SonarScanner: Downloaded SonarScanner for MSBuild from link https://docs.sonarqube.org/pages/viewpage.action?pageId=6954799

    Tuesday, February 26, 2019 10:50 AM