Add Sonar Support for .NET Project in Jenkins

My project is a .NET project, being built on running Jenkins. I would like to use Sonar to analyze this project to improve code quality.

Here are the steps to setup Sonar for .NET project:

  1. Download Sonar zip file, unzip and run bin/StartSonar.bat (on Windows 2008), then Sonar could be accessed from: http://localhost:9000
  2. Download and install(copy to Sonar plugins folder) .NET plugins for Sonar, http://docs.codehaus.org/display/SONAR/C-Sharp+Plugins+Ecosystem
  3. Install bunch tools for code quality: Gallio, FXCop, PartCover, Source Monitor, NDeps, according to http://choudhury.com/blog/2011/06/12/using-sonar-for-your-net-project/
  4. Download sonar runner, for future use.
  5. Download maven for future use.
  6. For 64-bit OS, use forFlags.exe to patch PartCover.exe and Gallio.Echo.exe, which are 32-bit, according to http://choudhury.com/blog/2011/06/12/using-sonar-for-your-net-project/
  7. Compile .NET solution/project under Debug but not Trunk, which are required by NDeps.
  8. Take following either way to analyze project:
    1. add sonar-project.properties under same folder with sln file, and add key ‘sonar.fxcop.installDirectory‘ with value of real FXCop installation in case console throws error. Do same thing for NDeps, as ‘sonar.ndeps.installDirectory
    2. add pom.xml, according to http://svn.codehaus.org/sonar-plugins/trunk/dotnet/tools/dotnet-tools-commons/src/test/resources/solution/Example/, and run ‘mvn clean install -Psonar-dotnet sonar:sonar
  9. Go to http://localhost:9000 to check Sonar report.

Add Sonar plugin in Jekins job – TBD

Share
 
张凯峰

张凯峰

ThoughtWorks程序员,InfoQ中文站编辑,有多年软件开发和测试经验,热衷参与技术社区与技术传播,参与翻译《Ajax实战》、《开源技术选型手册》。

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据