SonarCakeAliases Class

Summary

Contains functionality for running a Sonar analysis on a c# project using the MSBuild SonarQube Runner.

In order to use the commands for this addin, include the following in your build.cake file to download and reference from NuGet.org:

#addin "nuget:?package=Cake.Sonar"
#tool "nuget:?package=MSBuild.SonarQube.Runner.Tool"

Assembly
Cake.Sonar.dll
Namespace
Cake.Sonar
Base Types
  • Object
graph BT Type-->Base0["Object"] Type["SonarCakeAliases"] class Type type-node

Syntax

public static class SonarCakeAliases

Examples

Analysis is done in three phases. In the first phase, init, msbuild targets are added for collecting information. In the second phase, you build your projects and optionally a create a test- and coverage-report. In the third phasesonar will analyse the collectived files and process the passed reports. You can wrap the init and analysis phase around your existing tasks using dependencies with Cake.Sonar.SonarCakeAliases.SonarBegin(Cake.Core.ICakeContext,Cake.Sonar.SonarBeginSettings) and Cake.Sonar.SonarCakeAliases.SonarEnd(Cake.Core.ICakeContext):
Task("Sonar")
  .IsDependentOn("Sonar-Init") // should call SonarBegin()
  .IsDependentOn("Build")
  .IsDependentOn("Run-Unit-Test")
  .IsDependentOn("Sonar-Analyse"); // should call SonarEnd()
Or you can use a dedicated task that executed msbuild itself Cake.Sonar.SonarCakeAliases.Sonar(Cake.Core.ICakeContext,System.Action{Cake.Core.ICakeContext},Cake.Sonar.SonarBeginSettings). Tip: local testing of analysis can be done using sonarqube running in a docker container:
docker run -d --name sonarqube -p 9000:9000 -p 9092:9092 sonarqube

Attributes

Type Description
CakeAliasCategoryAttribute

Methods

Name Value Summary
Sonar(ICakeContext, Action<ICakeContext>, SonarBeginSettings) void
Run a self-contained analysis for the specified action. The action should run msbuild.
static
SonarBegin(ICakeContext, SonarBeginSettings) void
Initialise msbuild for sonar analysis.
static
SonarEnd(ICakeContext, SonarEndSettings) void
Run the actual sonar analysis and push them to sonar. This call should follow after a SonarBegin and MSBuild.
static
SonarEnd(ICakeContext) void
Run the actual sonar analysis (no credentials given).
static

Extension Methods

Name Value Summary
ToDictionary() IDictionary<string, object>
Requires the Cake.DeployParams addin