How to Set up Sonar on Jenkins for .net Projects

Source By: 

Historically, .Net projects have used technologies from within Microsoft stack to achieve their goals and objectives. With the strong emergence of excellent Open Source tools and the phenomenal growth of OpenStack, the trend is changing. Projects that use Microsoft Technologies are now seen building affinity towards open source tools for continuous integration, development and improvement. However, not many sites/tutorials are available, that helps a project in Microsoft Technology stack to leverage open source tools.

SonarQube is an open platform to manage code quality. This article guides a user on how to setup SonarQube in Jenkins server and simplify the adoption of the tool.

Installation of Sonarqube

1. Download SonarQube from
2. Unzip the SonarQube distribution C:\sonarqube
3. Start the SonarQube server:
4. Download SonarQube Runner from
5. Unzip the SonarQube Runner
6. Download examples
7. Unzip some project samples C:\sonar-examples
8. Analyze Project
cd C:\sonar-examples\projects\languages\java\sonar-runner\java-sonar-runner-simple
9. Browse results at http://localhost:9000
10. Default system administrator credentials are admin/admin

Install .Net Plugins for Sonar:

1. Download c# Ecosystem plugin from
2. Extract and copy the plugins to C:\sonarqube\extensions\plugins
3. Start SonarQube
4. Verify that you are able to browse http:// localhost:9000 and login
5. Login to the SonarQube website as an Admin user and
6. Click the “Settings” link in the upper right-hand corner,
7. Go to Configuration
8. Set the appropriate path for Galileo, FxCop, StyleCop and any other plugin that you want to invoke.
9. Install Win7 SDK if you are analyzing projects .net framework 2.0 /4.0; if the target framework is 4.5, install Win 8 SDK.
10. Download command-line tool from Resharper at:
11. Unzip it to a folder C:\jetbrains-commandline-tools
12. Go to update center -> Available plugins
13. Choose .Net Resharper
14. Restart the SonarQube server
15. Login to SonarQube using admin-admin

Modify Your Project’s Quality Profile

1. Activate all 650 Resharper rules
Go to Quality Profiles -> C# -> Sonar way
2. Run Sonar runner from solution file to ensure Sonar is working correctly.

Modify the port where Sonar is running

1. Change the sonar-properties files to have the port as 9010
sonar.web.port: 9010
sonar.web.context: /

2. Change the wrapper.conf and add following line

3. Run Sonar as a Windows Service

4. Start Sonar service

5. Change the Sonar runner properties file

Install SonarQube Plugin on Jenkins

1. Go to ‘Jenkins’ – ‘Manage Plugins’
2. Go to ‘Available tab’
3. Select ‘Sonar plugin’
4. Choose ‘install without restart’
5. Go to ‘Manage Jenkins’ and verify if ‘Sonar’ is listed in the installed plugin list.
6. You can verify your installed list.
7. Now go to http://jenkins IP/manage page
8. Go to ‘Configure System’:
9. Go to ‘Sonar configuration section’ and click on ‘Add Sonar:’
10. Go to ‘Configure sonar-runner’
11. Go to the ‘Build section’, click on ‘Add build step’ and choose ‘Invoke Standalone Sonar Analysis’: http://<IP>:<port>/job/<jobName>/configure
12. Add Invoke Standalone Sonar analysis
13. Configure the SonarQube analysis. You can either point to an existing file or set the analysis properties directly in the Project properties field:

Note : Following is a sample Sonar Properties file:

# Project identification
sonar.projectName= Sonar.TestApplication

# C# Specific Properties

sonar.dotnet.assemblies=/trunk/dotnet/vstudio/Sonar.TestApplication.Projects/Sonar.TestApplication.Data \bin\Debug\$(AssemblyName)\$(OutputType)

# Plugin Specific Properties


# Gallio / Unit Tests
sonar.opencover.installDirectory=C:/Program Files (x86)/OpenCover/

# FXCop

# StyleCop

14. Now the Sonar is setup
15. You can trigger Sonar either from Jenkins or from command prompt.

For further information, refer to

1Sonar project properties: A Sonar project file is the metadata that helps the sonar-runner to identify projects in the solution and run analysis against the solution. The Sonar runner file should be placed in the same folder that contains the c# solution. The Sonar runner file has three sections:
a. Project Properties
b. C# Specific Properties
c. Plugin Specific Properties

Comments:Comments 3

  • Solomon

    We’re a bunch of volunteers and starting a brand new scheme in our community. Your website offered us with useful information to work on. You’ve done a formidable job and our whole community can be thankful to you.

  • Pingback: 1 – Set Up Sonar on Jenkins for .net Projects | Offer Your()

  • Rakshith shetty

    I am using sonarqube5.1.2,jdk 1.8,sonarrunner 2.4,i can see the result of any java project in dashboard,but not even helloword program,when i use c# project for sonar analysis,using C# 4.2 plugin and os is xp (sp3)even for java and visual studio 2010.tell me what should i do to analyse any c# project.I am stucked,Iam getting”%1 is not win32 application”and sometime execution success but no output in dashboard.kindly help me



  • Subscribe for Blog Updates