Waffle

A very useful open source project I stumbled up on is waffle a Windows active directory authenication framework for C#/Java.

Using Sonar for your .Net project

Please note: Sonar .net plugins have been rewritten and version 1.0 has been released. Information on this blog relates to version 0.6 of the plugin. More information on the updated plugin can be found here

In my previous post, I covered how to install sonar, followed by how to setup a Java maven project to use sonar. You can also use sonar for your .net project – it’s not quite as straightforward as using it for Java, as you need to have various tools installed on the machine as prerequisites.

Firstly you need to install some plugins on the Sonar server. If your sonar server is running. You’ll need to stop it and then download the sonar .net plugins from the sonar .net plugin site and copy the jar files into you sonar extensions plugin folder.

The machine that will actually run the maven sonar analysis, will need to have a few prerequisites installed.

(1) Install Gallio onto your machine – With Gallio you can run different types of test frameworks, NUnit, MSTest, MBunit etc.. all under the one tool.

(2) Install FXCop 10, unfortunately this a little bit tricky, as only Visual Studio Premium comes shipped with FXCop 10, however, if you download and install the Windows SDK vers 7.1 (warning though, it’s a big download/install), you can install FXCop from the bin folder of the Windows SDK, follow instructions here

(3) Install PartCover 4 and install onto the machine (this allows you to get code coverage stats).

(4) Install source monitor onto your machine

The way sonar-net plugin works, is that it’s a maven plugin, so to build your Visual Studio solution, you actually have to use maven and create a pom.xml for your visual studio solution. So basically you will run maven and it will build your visual studio project for you and generate the sonar metrics for you.

Note if you are using 64 bit OS..

If you are using a 64 bit OS, currently you have to patch PartCover.exe and Gallio.Echo.exe to be 32 bits, otherwise you will not get any code coverage stats. You can patch the binaries using the tool CoreFlags.exe (this is provided in the windows sdk tool).

So open up a command prompt (but you have to open using “Run as Administrator” otherwise you’ll get a message unable to open file if you don’t).

path=C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin;%PATH%
cd "C:\Program Files (x86)\PartCover\PartCover .NET 4.0"
corFlags.exe PartCover.exe /32BIT+ /Force

cd "C:\Program Files (x86)\Gallio\bin"
corFlags.exe Gallio.Echo.exe /32BIT+ /Force

32 bit OS users can ignore the above step.

Here is the DistanceConverter-Net project to use, (again like the Java version, nothing much in it but enough to do a sonar analsysis). Note, this sample project is using NUnit for the unit tests, you will need to have NUnit installed on the machine to run sonar analysis. Unzip that to a directory run the command

mvn clean install -Psonar-dotnet sonar:sonar

If you’re running for the first time, expect it to take a while for the all maven dependencies to be downloaded. If all goes well, your sonar dashboard should be updated