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


"Every solution will only lead to new problems."

Sunday, 18. October 2009


xUnit.net support in “FAKE – F# Make” 0.14

Filed under: F#,FAKE - F# Make — Steffen Forkmann at 18:09 Uhr

Yesterday I released “FAKE – F# Make” version 0.14 with xUnit.net support. The usage is very easy and similar to the usage of NUnit:

Target "xUnitTest" (fun () -> 

  let testAssemblies =

    !+ (testDir + @"\Test.*.dll")

      |> Scan

 

  xUnit

    (fun p ->

       {p with

           ShadowCopy = false;

           HtmlPrefix = testDir})

    testAssemblies 

)

This sample works perfectly with TeamCity and creates a html-page per test project in addition:

TeamCity output

HMTL output

If you want to publish the xUnit.net test results in CruiseControl.NET just modify the build script a little:

Target "xUnitTest" (fun () -> 

  let testAssemblies =

    !+ (testDir + @"\Test.*.dll")

      |> Scan

 

  xUnit

    (fun p ->

       {p with

           ShadowCopy = false;

           HtmlPrefix = testDir;

           XmlPrefix = testDir })

    testAssemblies 

)

Now follow the steps in the CrusieControl.NET documentation. You will need to download the xUnitSummary.xsl file and save it to your webdashboard directory. If everything works correctly you should see something like this:

CruisControl.NET output

Tags: , , , , ,

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: , , , , , ,