Rash thoughts about .NET, C#, F# and Dynamics NAV.


"Every solution will only lead to new problems."

Wednesday, 14. October 2009


Integrating a “FAKE – F# Make” build script into CruiseControl.NET

Filed under: F#,FAKE - F# Make — Steffen Forkmann at 10:38 Uhr

Since version 0.12 the FAKE build system provides an easy way to setup build configurations for CruiseControl.NET.

“CruiseControl.NET is an Automated Continuous Integration server, implemented using the Microsoft .NET Framework.”

[thoughtworks.org]

In this article I will show you how you can set up a FAKE build script in CruiseControl.NET. We will use the CalculatorSample which you can download from the FAKE Download page.

If you want to know how this build script works and how you could create one for your own projects please read the “Getting started with FAKE”-tutorial.

If you want to set up “FAKE – F# Make” build configurations in TeamCity please read “Integrating a "FAKE – F# Make" build script into TeamCity”.

Installing CruiseControl.NET

You can download CruiseControl.NET from thoughtworks.org. After the installation process (further instructions) you should see an empty dashboard:

CruiseControl.NET Dashboard

Installing Subversion

The CalculatorSample is using Subversion (SVN) for SourceControl, so we need to download SVN from subversion.tigris.org. I’m using the “Windows MSI installer with the basic win32 binaries” and installed them under “c:\Program Files (x86)\Subversion\”.

Installing FxCop

The CalculatorSample is using FxCop, so we need to download and install it next.

“FxCop is an application that analyzes managed code assemblies (code that targets the .NET Framework common language runtime) and reports information about the assemblies, such as possible design, localization, performance, and security improvements. Many of the issues concern violations of the programming and design rules set forth in the Design Guidelines for Class Library Developers, which are the Microsoft guidelines for writing robust and easily maintainable code by using the .NET Framework.”

[MSDN]

Creating a FAKE Project

Now create a new folder for the CalculatorSample sources. I’m using “d:\Calculator\” for the rest of the article.

The next step is to modify the CruiseControl.NET config file (“c:\Program Files (x86)\CruiseControl.NET\server\ccnet.config” on my machine):

<cruisecontrol>

  <project>

    <name>CalculatorExample</name>

    <triggers>

       <intervalTrigger name="continuous" seconds="30" initialSeconds="30"/>

    </triggers>

    <sourcecontrol type="svn">

      <executable>c:\Program Files (x86)\Subversion\bin\svn.exe</executable>

      <workingDirectory>d:\Calculator\</workingDirectory>

      <trunkUrl>http://fake.googlecode.com/svn/trunk/Samples/Calculator/</trunkUrl>

    </sourcecontrol>   

    <tasks>

      <exec>

        <executable>d:\Calculator\tools\Fake\Fake.exe</executable>

        <baseDirectory>d:\Calculator\</baseDirectory>

        <buildArgs>completeBuild.fsx</buildArgs>

      </exec>

    </tasks>

    <publishers>

      <merge>

        <files>

          <file>d:\Calculator\test\FXCopResults.xml</file>

          <file>d:\Calculator\test\TestResults.xml</file>

          <file>d:\Calculator\output\Results.xml</file>

        </files>

      </merge>

      <xmllogger />

    </publishers>

  </project>

</cruisecontrol>

In this configuration I set up a trigger which checks every 30 sec. for changes in my CalculatorSample project.

If SVN finds changes FAKE.exe is called with my build script (completeBuild.fsx).

After the build I want to merge the FxCop and NUnit output files with my build results to create a build report.

Configuring the dashboard

In order to provide a nicer output on the dashboard we need to modify the BuildPlugins section in the dashboard.config file (“c:\Program Files (x86)\CruiseControl.NET\webdashboard\dashboard.config” on my machine):

<buildPlugins>

  <buildReportBuildPlugin>

    <xslFileNames>

      <xslFile>xsl\header.xsl</xslFile>

      <xslFile>xsl\modifications.xsl</xslFile>

      <xslFile>xsl\NCoverSummary.xsl</xslFile>

      <xslFile>xsl\fxcop-summary_1_36.xsl</xslFile>

      <xslFile>xsl\unittests.xsl</xslFile>

      <xslFile>xsl\nant.xsl</xslFile>

    </xslFileNames>

  </buildReportBuildPlugin>

  <buildLogBuildPlugin />

  <xslReportBuildPlugin

     description="NCover Report"

     actionName="NCoverBuildReport"

     xslFileName="xsl\NCover.xsl"></xslReportBuildPlugin>

  <xslReportBuildPlugin description="FxCop Report"

     actionName="FxCopBuildReport"

     xslFileName="xsl\fxcop-report_1_36.xsl" />

  <xslReportBuildPlugin description="NUnit Report"

     actionName="NUnitBuildReport"

     xslFileName="xsl\tests.xsl" />

</buildPlugins>

As you can see we use the nant.xsl to transform the FAKE output to HTML.

Starting the build

Now if everything is configured correctly, you can tell CruiseControl.NET to run your build (press “Start” for your build project on the dashboard):

Press Start on the dashboard

Now CruiseControl.NET should use SVN to checkout the CalculatorSample sources and run the build. The output on the project page for build 1 should look like this:

Build output

Build output 2

You can also inspect the NUnit and FxCop results:

 NUnit zest results

FxCop results

Please feel free to give feedback if you have any problems with this article.

https://denmarkapoteke.com
Tags: , , , , , ,

No Comments »

No comments yet.

RSS feed for comments on this post. | TrackBack URI

Leave a comment

XHTML ( You can use these tags): <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> .