<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Rash thoughts about .NET, C#, F# and Dynamics NAV. &#187; Fake</title>
	<atom:link href="http://www.navision-blog.de/tag/fake/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.navision-blog.de</link>
	<description>This Blog is about Microsoft Dynamics NAV (f.k.a Navision incl. C/SIDE and C/AL), C#, F# and .NET in general.</description>
	<lastBuildDate>Tue, 31 Jan 2012 17:13:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Machine.Fakes 0.1.0.0 released &#8211; Built with &quot;FAKE &#8211; F# Make&quot; 1.50.1.0</title>
		<link>http://www.navision-blog.de/2011/02/25/machine-fakes-0-1-0-0-released-built-with-fake-f-make-1-50-1-0/</link>
		<comments>http://www.navision-blog.de/2011/02/25/machine-fakes-0-1-0-0-released-built-with-fake-f-make-1-50-1-0/#comments</comments>
		<pubDate>Fri, 25 Feb 2011 14:09:44 +0000</pubDate>
		<dc:creator>Steffen Forkmann</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[FAKE - F# Make]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Fake]]></category>
		<category><![CDATA[Machine.Fakes]]></category>
		<category><![CDATA[Machine.Specifications]]></category>

		<guid isPermaLink="false">http://www.navision-blog.de/2011/02/25/machine-fakes-0-1-0-0-released-built-with-fake-f-make-1-50-1-0/</guid>
		<description><![CDATA[My friend Bj&#246;rn Rochel (@BjoernRochel) built a really cool generic model for using fakes and automocking on top of Machine.Specifications (or MSpec) called Machine.Fakes (or mfakes). Today he released version 0.1.0.0 (get it from nuget.org) and I want to talk a bit about the build process. Bj&#246;rn and myself thought a tool called “Machine.Fakes” should [...]]]></description>
			<content:encoded><![CDATA[<p><img style="span-left: 10px" align="right" src="http://www.navision-blog.de/images/machine.fakes.png" /> My friend <a href="http://nuget.org/Packages/ByAuthor/Bjoern%20Rochel">Bj&#246;rn Rochel</a> (<a href="http://twitter.com/#!/BjoernRochel">@BjoernRochel</a>) built a really cool generic model for using fakes and automocking on top of <a href="https://github.com/machine/machine.specifications">Machine.Specifications</a> (or MSpec) called <a href="Machine.Fakes">Machine.Fakes</a> (or mfakes). </p>
<p><script src="https://gist.github.com/843770.js"> </script></p>
<p>Today he released version 0.1.0.0 (get it from <a href="http://nuget.org/Packages/ByAuthor/Bjoern%20Rochel">nuget.org</a>) and I want to talk a bit about the build process. Bj&#246;rn and myself thought a tool called “Machine.Fakes” should of course be built with a tool called “FAKE – F# Make”. In order to do so I had to fix some stuff in Fake which resulted in the new <a href="http://teamcity.codebetter.com/repository/download/bt114/21897:id/FAKE-1.50.1.0.zip">Fake version 1.50.1.0</a>. </p>
<p>Here are some things I fixed:</p>
<ul>
<li>New task DeleteDirs allows to delete multiple directories. </li>
<li>New parameter for NuGet task which allows to specify dependencies. </li>
<li>Bundled with docu.exe compiled against .Net 4.0. </li>
<li>Fixed docu calls to run with full filenames. </li>
<li>Added targetplatform, target and log switches for ILMerge task. </li>
<li>Added Git.Information.getLastTag() which gets the last git tag by calling git describe. </li>
<li>Added Git.Information.getCurrentHash() which gets the last current sha1. </li>
</ul>
<h5>Machine.Fakes build setup</h5>
<p>The <a href="https://github.com/BjRo/Machine.Fakes/blob/dev/build.fsx">build script for Machine.Fakes</a> performs the following steps:</p>
<ol>
<li>It retrieves the version no. via <a href="http://github.com/api/v2/json/repos/show/BjRo/Machine.Fakes/tags">GitHubs REST API</a> </li>
<li>It cleans all directories from old stuff </li>
<li>It compiles the app and test projects </li>
<li>It uses MSpec to test the application </li>
<li>It merges StructureMap and StructureMap.AutoMocking into the app by using <a href="http://research.microsoft.com/en-us/people/mbarnett/ilmerge.aspx">ILMerge</a> </li>
<li>It generates the XML documentation using the <a href="https://github.com/forki/docu">.NET 4.0 version of docu.exe</a> </li>
<li>It zips the app and the documentation files </li>
<li>It builds and deploys a Nuget package with just <a href="http://nuget.org/Packages/Packages/Details/Machine-Fakes-0-1-0-0">Machine.Fakes</a> </li>
<li>It builds and deploys bundled Nuget packages in the following flavors:
<ol>
<li><a href="http://nuget.org/Packages/Packages/Details/Machine-Fakes-FakeItEasy-0-1-0-0">Machine.Fakes.FakeItEasy</a> </li>
<li><a href="http://nuget.org/Packages/Packages/Details/Machine-Fakes-RhinoMocks-0-1-0-0">Machine.Fakes.RhinoMocks</a> </li>
<li><a href="http://nuget.org/Packages/Packages/Details/Machine-Fakes-Moq-0-1-0-0">Machine.Fakes.Moq</a> </li>
</ol>
</li>
</ol>
<p>Now you can start using this awesome project by calling:</p>
<blockquote><p>install-package Machine.Fakes.{Flavor}</p>
</blockquote>
<p>&copy;2012 <a href="http://www.navision-blog.de">Rash thoughts about .NET, C#, F# and Dynamics NAV.</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.navision-blog.de/2011/02/25/machine-fakes-0-1-0-0-released-built-with-fake-f-make-1-50-1-0/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Running specific targets in &quot;FAKE &#8211; F# Make&quot;</title>
		<link>http://www.navision-blog.de/2010/11/03/running-specific-targets-in-fake-f-make/</link>
		<comments>http://www.navision-blog.de/2010/11/03/running-specific-targets-in-fake-f-make/#comments</comments>
		<pubDate>Wed, 03 Nov 2010 08:44:57 +0000</pubDate>
		<dc:creator>Steffen Forkmann</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[F-sharp Make]]></category>
		<category><![CDATA[Fake]]></category>

		<guid isPermaLink="false">http://www.navision-blog.de/2010/11/03/running-specific-targets-in-fake-f-make/</guid>
		<description><![CDATA[Most build tools allow to run a specific target via a special parameter in the command line. FAKE.exe doesn’t have such a parameter, but with a combination of the Run function and getBuildParamOrDefault we can achieve the same thing: 1: // include Fake libs 2: #I @&#34;tools\FAKE&#34; 3: #r &#34;FakeLib.dll&#34; 4: open Fake 5: 6: [...]]]></description>
			<content:encoded><![CDATA[<p>Most build tools allow to run a specific target via a special parameter in the command line. FAKE.exe doesn’t have such a parameter, but with a combination of the Run function and getBuildParamOrDefault we can achieve the same thing:</p>
<pre class="fssnip"><span class="l"> 1: </span><span class="c">//</span><span class="c"> </span><span class="c">include</span><span class="c"> </span><span class="c">Fake</span><span class="c"> </span><span class="c">libs</span>
<span class="l"> 2: </span><span class="prep">#I</span> <span class="s">@&quot;</span><span class="s">tools</span><span class="s">\</span><span class="s">FAKE</span><span class="s">&quot;</span>
<span class="l"> 3: </span><span class="prep">#r</span> <span class="s">&quot;</span><span class="s">FakeLib</span><span class="s">.</span><span class="s">dll</span><span class="s">&quot;</span>
<span class="l"> 4: </span><span class="k">open</span> <span class="i">Fake</span>
<span class="l"> 5: </span>
<span class="l"> 6: </span><span class="c">//</span><span class="c"> </span><span class="c">***</span><span class="c"> </span><span class="c">Define</span><span class="c"> </span><span class="c">Targets</span><span class="c"> </span><span class="c">***</span>
<span class="l"> 7: </span><span class="i">Target</span> <span class="s">&quot;</span><span class="s">Clean</span><span class="s">&quot;</span> (<span class="k">fun</span> () <span class="k">-&gt;</span>
<span class="l"> 8: </span>    <span class="i">trace</span> <span class="s">&quot;</span><span class="s"> </span><span class="s">-</span><span class="s">-</span><span class="s">-</span><span class="s"> </span><span class="s">Cleaning</span><span class="s"> </span><span class="s">stuff</span><span class="s"> </span><span class="s">-</span><span class="s">-</span><span class="s">-</span><span class="s"> </span><span class="s">&quot;</span>
<span class="l"> 9: </span>)
<span class="l">10: </span>
<span class="l">11: </span><span class="i">Target</span> <span class="s">&quot;</span><span class="s">Build</span><span class="s">&quot;</span> (<span class="k">fun</span> () <span class="k">-&gt;</span>
<span class="l">12: </span>    <span class="i">trace</span> <span class="s">&quot;</span><span class="s"> </span><span class="s">-</span><span class="s">-</span><span class="s">-</span><span class="s"> </span><span class="s">Building</span><span class="s"> </span><span class="s">the</span><span class="s"> </span><span class="s">app</span><span class="s"> </span><span class="s">-</span><span class="s">-</span><span class="s">-</span><span class="s"> </span><span class="s">&quot;</span>
<span class="l">13: </span>)
<span class="l">14: </span>
<span class="l">15: </span><span class="i">Target</span> <span class="s">&quot;</span><span class="s">Deploy</span><span class="s">&quot;</span> (<span class="k">fun</span> () <span class="k">-&gt;</span>
<span class="l">16: </span>    <span class="i">trace</span> <span class="s">&quot;</span><span class="s"> </span><span class="s">-</span><span class="s">-</span><span class="s">-</span><span class="s"> </span><span class="s">Deploying</span><span class="s"> </span><span class="s">app</span><span class="s"> </span><span class="s">-</span><span class="s">-</span><span class="s">-</span><span class="s"> </span><span class="s">&quot;</span>
<span class="l">17: </span>)
<span class="l">18: </span>
<span class="l">19: </span><span class="c">//</span><span class="c"> </span><span class="c">***</span><span class="c"> </span><span class="c">Define</span><span class="c"> </span><span class="c">Dependencies</span><span class="c"> </span><span class="c">***</span>
<span class="l">20: </span><span class="s">&quot;</span><span class="s">Build</span><span class="s">&quot;</span>  <span class="o">&lt;==</span> [<span class="s">&quot;</span><span class="s">Clean</span><span class="s">&quot;</span>]
<span class="l">21: </span><span class="s">&quot;</span><span class="s">Deploy</span><span class="s">&quot;</span>  <span class="o">&lt;==</span> [<span class="s">&quot;</span><span class="s">Build</span><span class="s">&quot;</span>]
<span class="l">22: </span>
<span class="l">23: </span><span class="c">//</span><span class="c"> </span><span class="c">***</span><span class="c"> </span><span class="c">Start</span><span class="c"> </span><span class="c">Build</span><span class="c"> </span><span class="c">***</span>
<span class="l">24: </span><span class="i">Run</span> <span class="o">&lt;|</span> <span class="i">getBuildParamOrDefault</span> <span class="s">&quot;</span><span class="s">target</span><span class="s">&quot;</span> <span class="s">&quot;</span><span class="s">Default</span><span class="s">&quot;</span></pre>
<p>Now we can start the Deploy target by simply calling FAKE without a target parameter and if we want to start only the Clean target we could write “tools\<em>Fake.exe build.fsx target=Clean</em>”.</p>
<p>&copy;2012 <a href="http://www.navision-blog.de">Rash thoughts about .NET, C#, F# and Dynamics NAV.</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.navision-blog.de/2010/11/03/running-specific-targets-in-fake-f-make/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>&quot;Fake &#8211; F# Make&quot; 1.40.5.0 released &#8211; Bugfixes for CruiseControl.NET</title>
		<link>http://www.navision-blog.de/2010/07/14/fake-f-make-1-40-5-0-released-bugfixes-for-cruisecontrol-net/</link>
		<comments>http://www.navision-blog.de/2010/07/14/fake-f-make-1-40-5-0-released-bugfixes-for-cruisecontrol-net/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 09:15:05 +0000</pubDate>
		<dc:creator>Steffen Forkmann</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[FAKE - F# Make]]></category>
		<category><![CDATA[docu]]></category>
		<category><![CDATA[F-sharp Make]]></category>
		<category><![CDATA[Fake]]></category>

		<guid isPermaLink="false">http://www.navision-blog.de/2010/07/14/fake-f-make-1-40-5-0-released-bugfixes-for-cruisecontrol-net/</guid>
		<description><![CDATA[Today I released “FAKE – F# Make” version 1.40.5.0. This release fixes some issues with CruiseControl.NET compatibility and improves the MSBuild task. Important links: Project page Download HTML Documentation Repository Changes for CruiseControl.NET Daniel Nauck created a FAKE task for CC.Net. This task allows a much easier configuration of FAKE. Please download the latest CC.NET [...]]]></description>
			<content:encoded><![CDATA[<p>Today I released “FAKE – F# Make” version 1.40.5.0. This release fixes some issues with <a href="http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET">CruiseControl.NET</a> compatibility and improves the MSBuild task.</p>
<p>Important links:</p>
<ul>
<li><a href="http://bitbucket.org/forki/fake/wiki/Home">Project page</a></li>
<li><a href="http://bitbucket.org/forki/fake/downloads">Download</a></li>
<li><a href="http://www.navision-blog.de/fake/">HTML Documentation</a></li>
<li><a href="http://github.com/forki/FAKE">Repository</a></li>
<li><script src="http://www.ohloh.net/p/483999/widgets/project_thin_badge.js" type="text/javascript"></script></li>
</ul>
<h5>Changes for CruiseControl.NET</h5>
<p><a href="http://twitter.com/dnauck">Daniel Nauck</a> created a <a href="http://confluence.public.thoughtworks.org/display/CCNET/FAKE+Task">FAKE task for CC.Net</a>. This task allows a much easier configuration of FAKE. Please download the <a href="http://ccnetlive.thoughtworks.com/CCNet-builds/1.6.0/">latest CC.NET build</a> if you want to use it.</p>
<p>Daniel also created a <a href="http://build.nauck-it.de/server/build.nauck-it.de/ViewServerReport.aspx?Category=FAKE">FAKE build project on his server</a> which showed us some compatibility issues:</p>
<ul>
<li>In FAKE:
<ul>
<li>Race condition in FAKE’s trace functionality</li>
<li>Better XML tracing if something fails</li>
<li>The tracing buffer will be flushed after every build target</li>
<li>Every task has a Timeout property (Default: 5 min.)</li>
<li>Setting of environment variables fixed</li>
<li><a href="http://www.nunit.org/index.php?p=consoleCommandLine&amp;r=2.2">Showing labels in NUnit</a> is now the default</li>
</ul>
</li>
<li>In <a href="http://docu.jagregory.com/">Docu</a>:
<ul>
<li><a href="http://github.com/forki/docu/commit/80daa6b48cb7f652ff5646a45fce4b94619fad1f">Unhandled exception in Docu.exe</a></li>
</ul>
</li>
<li>In CC.NET:
<ul>
<li>Implemented <a href="http://confluence.public.thoughtworks.org/display/CCNET/Git+Source+Control+Block">support for git submodules</a> (<a href="http://jira.public.thoughtworks.org/browse/CCNET-1922">CCNET-1922</a>)</li>
</ul>
</li>
</ul>
<p>@Daniel: Thank you very much for helping me on this CruiseControl.NET stuff. I really appreciate this.</p>
<h5>MSBuild task changes</h5>
<p>The MSBuild task in FAKE gets a sequence of project files and compiles them in the given order. This might be slow if you have lots of dependent projects. Then MSBuild might analyze the dependencies over and over again. To fix this issue I currently see two possible solutions:</p>
<ol>
<li>Generate a temporary solution file and use this for compilation.</li>
<li>Analyze the given projects and remove all dependent projects from the list.</li>
</ol>
<p>FAKE 1.40.5.0 implements the second idea. If you have a better idea please contact me.</p>
<p>&copy;2012 <a href="http://www.navision-blog.de">Rash thoughts about .NET, C#, F# and Dynamics NAV.</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.navision-blog.de/2010/07/14/fake-f-make-1-40-5-0-released-bugfixes-for-cruisecontrol-net/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>&#8220;Fake &#8211; F# Make&#8221; 1.33.0 released</title>
		<link>http://www.navision-blog.de/2010/07/11/fake-f-make-1-33-0-released/</link>
		<comments>http://www.navision-blog.de/2010/07/11/fake-f-make-1-33-0-released/#comments</comments>
		<pubDate>Sun, 11 Jul 2010 15:11:49 +0000</pubDate>
		<dc:creator>Steffen Forkmann</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[FAKE - F# Make]]></category>
		<category><![CDATA[F-sharp Make]]></category>
		<category><![CDATA[Fake]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[SideBySideSpecification]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[XPath]]></category>

		<guid isPermaLink="false">http://www.navision-blog.de/2010/07/11/fake-f-make-1-33-0-released/</guid>
		<description><![CDATA[Yesterday I released “FAKE – F# Make” version 1.33.0. This release has lots of small bug fixes and a couple of new features. Important links: Project page Download Repository Git helpers -Fake.Git.dll Git is a distributed revision control system with an emphasis on speed. Git was initially designed and developed by Linus Torvalds for Linux [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I released “FAKE – F# Make” version 1.33.0. This release has lots of small bug fixes and a couple of new features.</p>
<p>Important links:</p>
<ul>
<li><a href="http://bitbucket.org/forki/fake/wiki/Home">Project page</a></li>
<li><a href="http://bitbucket.org/forki/fake/downloads">Download</a></li>
<li><a href="http://github.com/forki/FAKE">Repository</a></li>
</ul>
<h5>Git helpers -Fake.Git.dll</h5>
<blockquote><p>Git is a distributed revision control system with an emphasis on speed. Git was initially designed and developed by Linus Torvalds for Linux kernel development. Every Git working directory is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server.</p>
<p>[<a href="http://en.wikipedia.org/wiki/Git_%28software%29">Wikipedia</a>]</p></blockquote>
<p>In the last couple of months I worked on small helper library for controlling <a href="http://en.wikipedia.org/wiki/Git_%28software%29">Git</a>. This library is now released as part of “FAKE – F# Make”. You can find the source code at <a title="http://github.com/forki/FAKE/tree/master/src/app/Fake.Git/" href="http://github.com/forki/FAKE/tree/master/src/app/Fake.Git/">http://github.com/forki/FAKE/tree/master/src/app/Fake.Git/</a>.</p>
<p>Features:</p>
<ul>
<li>Repository handling
<ul>
<li>init, clone</li>
</ul>
</li>
<li>Submodules
<ul>
<li>init, clone, information about submodules</li>
</ul>
</li>
<li>Branches
<ul>
<li>checkout, create, delete, merge, rebase, tag, pull, push, reset, commit, …</li>
</ul>
</li>
<li>SHA1 calculation</li>
</ul>
<h5>Documentation generation with James Gregory&#8217;s docu tool</h5>
<blockquote><p><strong>What&#8217;s a docu?</strong> A documentation generator for .Net that isn&#8217;t complicated, awkward, or difficult to use. Given an assembly and the XML that&#8217;s generated by Visual Studio, docu can produce an entire website of documentation with a single command.</p>
<p>[<a href="http://docu.jagregory.com/">docu website</a>]</p></blockquote>
<p>Fake comes bundled with James Gregory’s documentations generator “<a href="http://docu.jagregory.com/">docu</a>”, which converts <a href="http://msdn.microsoft.com/en-us/library/b2s063f7%28VS.71%29.aspx">XML-Documentation</a> comments into HTML files. All you need to do is downloading a <a href="http://bitbucket.org/forki/fake/downloads/templates.zip">template</a> and calling the docu task inside your build script:</p>
<pre style="font-family: consolas;">!+ (buildDir + <span style="color: maroon;">"*.dll"</span>)
     |&gt; Scan
     |&gt; Docu (<span style="color: blue;">fun</span> p <span style="color: blue;">-&gt;
</span>         {p <span style="color: blue;">with
</span>             ToolPath = docuPath + <span style="color: maroon;">"docu.exe"</span>
             TemplatesPath = templatesSrcDir
             OutputPath = docsDir })</pre>
<p>Since FAKE builds its own documentation with docu I started to add more (and hopefully better) XML doc comments. My plan is to describe more and more of the internal FAKE functions in the next releases. An updated HTML-document (generated via a <a href="http://docu.jagregory.com/">docu</a> task) can be found at <a title="http://www.navision-blog.de/fake/" href="http://www.navision-blog.de/fake/">http://www.navision-blog.de/fake/</a>.</p>
<h5>Side by side specification</h5>
<p>For Test-driven development (TDD) it’s sometimes nice to have the specifications next to the implementation files since the specs are considered as documentation.</p>
<p>By using a tool like <a title="VsCommands" href="http://mokosh.co.uk/vscommands/">VSCommands</a> it is possible to group the implementation with the specs (see also <a href="http://gist.github.com/457248">http://gist.github.com/457248</a>).</p>
<p>This “side by side specification” makes TDD a lot easier but of course  we don&#8217;t want to deploy the specification classes and the test data.</p>
<table>
<tbody>
<tr>
<td><img style="display: inline; border-width: 0px;" title="Side by side specification" src="http://www.navision-blog.de/images/FakeFMake1.33.0released_B55F/image.png" border="0" alt="Side by side specification" width="221" height="201" /></td>
<td>==&gt;</td>
<td><img style="display: inline; border-width: 0px;" title="After &quot;RemoveTestFromProject&quot;" src="http://www.navision-blog.de/images/FakeFMake1.33.0released_B55F/image_3.png" border="0" alt="After &quot;RemoveTestFromProject&quot;" width="142" height="117" /></td>
</tr>
</tbody>
</table>
<p>FAKE has a new feature which automatically removes all specification files and test framework references according to a given convention:</p>
<pre style="font-family: consolas;">Target <span style="color: maroon;">"BuildApp"</span> (<span style="color: blue;">fun</span> _ –<span style="color: blue;">&gt;
</span>      !+ <span style="color: maroon;">@"src\app\**\*.csproj"</span>
         |&gt; Scan
         |&gt; <strong>Seq.map (
             RemoveTestsFromProject
                 AllNUnitReferences      <span style="color: green;">// a default references convention</span>
                 AllSpecAndTestDataFiles <span style="color: green;">// a default file convention
</span>                 )</strong>
         |&gt; MSBuildRelease buildDir <span style="color: maroon;">"Build"</span>
         |&gt; Log <span style="color: maroon;">"AppBuild-Output: "</span>
)</pre>
<p>The conventions are simple functions and can be customized e.g.:</p>
<pre style="font-family: consolas;"><span style="color: green;">/// All Spec.cs or Spec.fs files and all files containing TestData</span>
<span style="color: blue;">let</span> AllSpecAndTestDataFiles elementName (s:string) =
     s.EndsWith <span style="color: maroon;">"Specs.cs"</span> ||
       s.EndsWith <span style="color: maroon;">"Specs.fs"</span> ||
       (elementName = <span style="color: maroon;">"Content"</span> &amp;&amp; s.Contains <span style="color: maroon;">"TestData"</span>)</pre>
<h5>Miscellaneous</h5>
<ul>
<li>SQL Server helpers are moved to Fake.SQL.dll
<ul>
<li>Additional functions for attaching and detaching databases.</li>
</ul>
</li>
<li>FileHelper.CopyCached function was added
<ul>
<li>Copies the files from a cache folder. If the files are not cached or the original files have a different write time the cache will be refreshed.</li>
</ul>
</li>
<li>EnvironmentHelper.environVarOrDefault added
<ul>
<li>Retrieves the environment variable or a given default.</li>
</ul>
</li>
<li>Fixed <a href="http://github.com/forki/FAKE/issues/closed#issue/3">Issue 3</a>: toRelativePath calculates paths with ..\..\ if needed</li>
<li>Added a build time report to the build output.</li>
<li>XPathReplace and XMLPoke tasks added.
<ul>
<li>Replaces text in an XML file at the location specified by an XPath expression.</li>
</ul>
</li>
<li><a href="http://research.microsoft.com/en-us/people/mbarnett/ilmerge.aspx">ILMerge</a> task added</li>
<li><a href="http://wix.sourceforge.net/">Windows Installer XML (WiX)</a> task added</li>
</ul>
<p>&copy;2012 <a href="http://www.navision-blog.de">Rash thoughts about .NET, C#, F# and Dynamics NAV.</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.navision-blog.de/2010/07/11/fake-f-make-1-33-0-released/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using a MailboxProcessor to speedup &#8220;FAKE &#8211; F# MAKE&#8221;</title>
		<link>http://www.navision-blog.de/2010/05/07/using-a-mailboxprocessor-to-speedup-fake-f-make/</link>
		<comments>http://www.navision-blog.de/2010/05/07/using-a-mailboxprocessor-to-speedup-fake-f-make/#comments</comments>
		<pubDate>Fri, 07 May 2010 11:37:28 +0000</pubDate>
		<dc:creator>Steffen Forkmann</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[FAKE - F# Make]]></category>
		<category><![CDATA[F-sharp Make]]></category>
		<category><![CDATA[Fake]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://www.navision-blog.de/2010/05/07/using-a-mailboxprocessor-to-speedup-fake-f-make/</guid>
		<description><![CDATA[Earlier today I released “FAKE – F# Make” version 1.10.0. This new release contains a lot path issue fixes for Mono and a new architecture for logging and tracing. A guy named Joel Mueller had an awesome idea and sent me some patches. He noticed that TraceHelper.fs writes all messages synchronously to the console and/or [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier today I released <a href="http://bitbucket.org/forki/fake/downloads">“FAKE – F# Make” version 1.10.0</a>. This new release contains a lot path issue fixes for <a href="http://www.mono-project.com/Main_Page">Mono</a> and a new architecture for logging and tracing. </p>
<p>A guy named Joel Mueller had an awesome idea and sent me some patches. He noticed that TraceHelper.fs writes all messages synchronously to the console and/or a XML output file, which means the actual build operations must wait on the writing of hundreds of trace messages, slowing down the actual build.</p>
<p>His idea was to use a MailboxProcessor to buffer up the trace messages and write them out asynchronously, so that the actual build can proceed at full speed.</p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<p style="margin: 0px"><span style="color: blue">type</span> Message = </p>
<p style="margin: 0px">&#160;&#160;&#160; { Text&#160;&#160;&#160;&#160;&#160; : string</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160; Color&#160;&#160;&#160;&#160; : ConsoleColor</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160; Newline&#160;&#160; : bool</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160; Important : bool}</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: green">/// &#8230;.</span></p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: blue">let</span> buffer = MailboxProcessor.Start (<span style="color: blue">fun</span> inbox <span style="color: blue">-&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">let</span> <span style="color: blue">rec</span> loop () = </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; async {</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">let!</span> (msg:Message) = inbox.Receive()</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">match</span> traceMode <span style="color: blue">with</span></p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | Console <span style="color: blue">-&gt;</span> logMessageToConsole msg</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; | Xml&#160;&#160;&#160;&#160; <span style="color: blue">-&gt;</span> appendXML msg.Text</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color: blue">return!</span> loop ()}</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;&#160;&#160; loop ())&#160;&#160;&#160;&#160;&#160; </p>
</p></div>
<p>Now all internal logging and tracing functions can post their their messages to the inbox of the MailboxProcessor:</p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<p style="margin: 0px"><span style="color: green">/// Logs the specified string (via message buffer)</span></p>
<p style="margin: 0px"><span style="color: blue">let</span> logMessage important newLine message =</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">match</span> traceMode <span style="color: blue">with</span></p>
<p style="margin: 0px">&#160;&#160;&#160; | Console <span style="color: blue">-&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; { Text = message; </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Important = important; </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Newline = newLine; </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Color = ConsoleColor.White }</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; |&gt; buffer.Post</p>
<p style="margin: 0px">&#160;&#160;&#160; | Xml&#160;&#160;&#160;&#160; <span style="color: blue">-&gt;</span> </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160; { defaultMessage <span style="color: blue">with</span> </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Text = sprintf <span style="color: maroon">&quot;&lt;message&gt;&lt;![CDATA[%s]]&gt;&lt;/message&gt;&quot;</span> </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; message }</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; |&gt; buffer.Post </p>
</p></div>
<p>This idea reduces the build time of FAKE’s self build from 3 min. to 2 min. Which is really amazing, since I didn’t have to change anything in the build script. This version is compatible to the last released version.</p>
<p>Please download <a href="http://bitbucket.org/forki/fake/downloads">“FAKE – F# Make” version 1.10.0</a> and tell me what you think.</p>
<p>&copy;2012 <a href="http://www.navision-blog.de">Rash thoughts about .NET, C#, F# and Dynamics NAV.</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.navision-blog.de/2010/05/07/using-a-mailboxprocessor-to-speedup-fake-f-make/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>New syntactic sugar for &#8220;FAKE &#8211; F# Make&#8221; &#8211; Getting rid of magic strings</title>
		<link>http://www.navision-blog.de/2010/02/08/new-syntactic-sugar-for-fake-f-make-getting-rid-of-magic-strings/</link>
		<comments>http://www.navision-blog.de/2010/02/08/new-syntactic-sugar-for-fake-f-make-getting-rid-of-magic-strings/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 17:58:12 +0000</pubDate>
		<dc:creator>Steffen Forkmann</dc:creator>
				<category><![CDATA[English posts]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[FAKE - F# Make]]></category>
		<category><![CDATA[F-sharp Make]]></category>
		<category><![CDATA[Fake]]></category>

		<guid isPermaLink="false">http://www.navision-blog.de/2010/02/08/new-syntactic-sugar-for-fake-f-make-getting-rid-of-magic-strings/</guid>
		<description><![CDATA[The new version 0.27 of “FAKE – F# Make” comes with new syntactic sugar for build targets and build dependencies. Don’t be afraid the old version is still supported &#8211; all scripts should still work with the new version. The problem Consider the following target definition: let buildDir = &#34;./build/&#34; &#160; Target &#34;Clean&#34; (fun _ [...]]]></description>
			<content:encoded><![CDATA[<p>The new version 0.27 of “FAKE – F# Make” comes with new syntactic sugar for build targets and build dependencies. Don’t be afraid the old version is still supported &#8211; all scripts should still work with the new version.</p>
<h5>The problem</h5>
<p>Consider the following target definition:</p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<p style="margin: 0px"><span style="color: blue">let</span> buildDir = <span style="color: maroon">&quot;./build/&quot;</span></p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">Target <span style="color: maroon">&quot;Clean&quot;</span> (<span style="color: blue">fun</span> _ <span style="color: blue">-&gt;</span></p>
<p style="margin: 0px">&#160; CleanDir buildDir</p>
<p style="margin: 0px">)</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">Target <span style="color: maroon">&quot;Default&quot;</span> (<span style="color: blue">fun</span> _ <span style="color: blue">-&gt;</span></p>
<p style="margin: 0px">&#160; trace <span style="color: maroon">&quot;Hello World from FAKE&quot;</span></p>
<p style="margin: 0px">)</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: maroon">&quot;Default&quot;</span> &lt;== [<span style="color: maroon">&quot;Clean&quot;</span>]</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">run <span style="color: maroon">&quot;Default&quot;</span></p>
</p></div>
<p>As you can see we are having a lot of “magic strings” for the target names and the dependency definitions. This was always a small shortcoming in FAKE, since this doesn’t allow refactoring and may result in runtime errors. </p>
<p>One of my goals for “FAKE – F# Make” is to remove these strings in future versions. Unfortunately this is not that easy, because it causes a lot of internal issues. In particular logging to the build server is much harder if you don’t have a target name.</p>
<h5></h5>
<h5>The first step</h5>
<p>As posted in a <a href="http://bitbucket.org/forki/fake/issue/5/mono-support-is-not-working">bitbucket</a> comment by <a href="http://bitbucket.org/cipher/">cipher</a> we could use the “<a href="http://weblogs.asp.net/podwysocki/archive/2010/02/05/using-and-abusing-the-f-dynamic-lookup-operator.aspx">dynamic lookup operator</a>” to remove some of the magic strings without breaking any internal code.</p>
<p>As a result we can rewrite the above sample as:</p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<p style="margin: 0px"><span style="color: blue">let</span> buildDir = <span style="color: maroon">&quot;./build/&quot;</span></p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">Target? Clean &lt;-</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">fun</span> _ <span style="color: blue">-&gt;</span> CleanDir buildDir</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">Target? Default &lt;-</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">fun</span> _ <span style="color: blue">-&gt;</span> trace <span style="color: maroon">&quot;Hello World from FAKE&quot;</span></p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">For? Default &lt;- Dependency? Clean</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">Run? Default</p>
</p></div>
<p>All magic strings suddenly disappeared. I think this syntax looks really nice, but unfortunately the strings are not really gone, since the token <strong>Default</strong> is only checked at runtime.</p>
<h5>The idea for future versions</h5>
<p>Since the new syntax is really just syntactic sugar I’m always interested in a better solution. Currently I’m working on a syntax using monads. The result could look like this:</p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<p style="margin: 0px"><span style="color: blue">let</span> buildDir = <span style="color: maroon">&quot;./build/&quot;</span></p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: blue">let</span> Clean = target { CleanDir buildDir }</p>
<p style="margin: 0px"><span style="color: blue">let</span> Default = </p>
<p style="margin: 0px">&#160; target { </p>
<p style="margin: 0px">&#160;&#160;&#160; trace <span style="color: maroon">&quot;Hello World from FAKE&quot;</span> </p>
<p style="margin: 0px">&#160;&#160;&#160; trace <span style="color: maroon">&quot;Another line&quot;</span></p>
<p style="margin: 0px">&#160; }</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">Default &lt;== [Clean]</p>
<p style="margin: 0px"><span style="color: green"></span></p>
</p></div>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<p style="margin: 0px">Run Default</p>
</p></div>
<p>This way the magic string are really gone, but my current problem is retrieving the target name from the let-binding name. Please leave a comment if you have an idea to solve this issue.</p>
<p>&copy;2012 <a href="http://www.navision-blog.de">Rash thoughts about .NET, C#, F# and Dynamics NAV.</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.navision-blog.de/2010/02/08/new-syntactic-sugar-for-fake-f-make-getting-rid-of-magic-strings/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>xUnit.net support in &#8220;FAKE &#8211; F# Make&#8221; 0.14</title>
		<link>http://www.navision-blog.de/2009/10/18/xunit-support-in-fake-f-make-0-14/</link>
		<comments>http://www.navision-blog.de/2009/10/18/xunit-support-in-fake-f-make-0-14/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 16:09:16 +0000</pubDate>
		<dc:creator>Steffen Forkmann</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[FAKE - F# Make]]></category>
		<category><![CDATA[CruiseControl.NET]]></category>
		<category><![CDATA[F-sharp Make]]></category>
		<category><![CDATA[Fake]]></category>
		<category><![CDATA[nunit]]></category>
		<category><![CDATA[xUnit.net. TeamCity]]></category>

		<guid isPermaLink="false">http://www.navision-blog.de/2009/10/18/xunit-support-in-fake-f-make-0-14/</guid>
		<description><![CDATA[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 &#34;xUnitTest&#34; (fun () -&#62;&#160; &#160; let testAssemblies = &#160;&#160;&#160; !+ (testDir + @&#34;\Test.*.dll&#34;) &#160;&#160;&#160;&#160;&#160; &#124;&#62; Scan &#160; &#160; xUnit &#160;&#160;&#160; (fun p -&#62; &#160;&#160;&#160;&#160;&#160;&#160; {p with &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ShadowCopy = false; [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I released <a href="http://code.google.com/p/fake/">“FAKE – F# Make”</a> version 0.14 with <a href="http://www.codeplex.com/xunit">xUnit.net</a> support. The usage is very easy and similar to the usage of NUnit: </p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<p style="margin: 0px">Target <span style="color: maroon">&quot;xUnitTest&quot;</span> (<span style="color: blue">fun</span> () <span style="color: blue">-&gt;</span>&#160; </p>
<p style="margin: 0px">&#160; <span style="color: blue">let</span> testAssemblies = </p>
<p style="margin: 0px">&#160;&#160;&#160; !+ (testDir + <span style="color: maroon">@&quot;\Test.*.dll&quot;</span>) </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160; |&gt; Scan</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160; xUnit </p>
<p style="margin: 0px">&#160;&#160;&#160; (<span style="color: blue">fun</span> p <span style="color: blue">-&gt;</span> </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160; {p <span style="color: blue">with</span> </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ShadowCopy = <span style="color: blue">false</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; HtmlPrefix = testDir}) </p>
<p style="margin: 0px">&#160;&#160;&#160; testAssemblies&#160; </p>
<p style="margin: 0px">)</p>
</p></div>
<p>This sample works perfectly with <a href="http://www.jetbrains.com/teamcity/">TeamCity</a> and creates a html-page per test project in addition:</p>
<p><img class="bordered" title="TeamCity output" alt="TeamCity output" src="http://www.navision-blog.de/images/xUnitsupportinFAKEFMake0.14_FF4A/image.png" width="500" height="279" /></p>
<p><img class="bordered" title="HMTL output" alt="HMTL output" src="http://www.navision-blog.de/images/xUnitsupportinFAKEFMake0.14_FF4A/image_3.png" width="500" height="135" /></p>
<p>If you want to publish the xUnit.net test results in <a href="http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET">CruiseControl.NET</a> just modify the build script a little:</p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<p style="margin: 0px">Target <span style="color: maroon">&quot;xUnitTest&quot;</span> (<span style="color: blue">fun</span> () <span style="color: blue">-&gt;</span>&#160; </p>
<p style="margin: 0px">&#160; <span style="color: blue">let</span> testAssemblies = </p>
<p style="margin: 0px">&#160;&#160;&#160; !+ (testDir + <span style="color: maroon">@&quot;\Test.*.dll&quot;</span>) </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160; |&gt; Scan</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160; xUnit </p>
<p style="margin: 0px">&#160;&#160;&#160; (<span style="color: blue">fun</span> p <span style="color: blue">-&gt;</span> </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160; {p <span style="color: blue">with</span> </p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ShadowCopy = <span style="color: blue">false</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; HtmlPrefix = testDir;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <strong>XmlPrefix = testDir</strong> }) </p>
<p style="margin: 0px">&#160;&#160;&#160; testAssemblies&#160; </p>
<p style="margin: 0px">)</p>
</p></div>
<p>Now follow the steps in the <a href="http://xunit.codeplex.com/wikipage?title=HowToUseCcNet&amp;ProjectName=xunit">CrusieControl.NET documentation</a>. You will need to download the <a href="http://xunit.codeplex.com/">xUnitSummary.xsl</a> file and save it to your webdashboard directory. If everything works correctly you should see something like this:</p>
<p><img class="bordered" title="CruisControl.NET output" alt="CruisControl.NET output" src="http://www.navision-blog.de/images/xUnitsupportinFAKEFMake0.14_FF4A/image_4.png" width="500" height="300" /></p>
<p>&copy;2012 <a href="http://www.navision-blog.de">Rash thoughts about .NET, C#, F# and Dynamics NAV.</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.navision-blog.de/2009/10/18/xunit-support-in-fake-f-make-0-14/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Integrating a &#8220;FAKE &#8211; F# Make&#8221; build script into CruiseControl.NET</title>
		<link>http://www.navision-blog.de/2009/10/14/integrating-a-fake-f-make-build-script-into-cruisecontrol-net/</link>
		<comments>http://www.navision-blog.de/2009/10/14/integrating-a-fake-f-make-build-script-into-cruisecontrol-net/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 08:38:55 +0000</pubDate>
		<dc:creator>Steffen Forkmann</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[FAKE - F# Make]]></category>
		<category><![CDATA[CC.NET]]></category>
		<category><![CDATA[Continuous Integration]]></category>
		<category><![CDATA[CruiseControl]]></category>
		<category><![CDATA[CruiseControl.NET]]></category>
		<category><![CDATA[F-sharp Make]]></category>
		<category><![CDATA[Fake]]></category>

		<guid isPermaLink="false">http://www.navision-blog.de/2009/10/14/integrating-a-fake-f-make-build-script-into-cruisecontrol-net/</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<p>Since version 0.12 the <a href="http://code.google.com/p/fake/">FAKE build system</a> provides an easy way to setup build configurations for <a href="http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET">CruiseControl.NET</a>.</p>
<blockquote><p><strong>“CruiseControl.NET</strong> is an Automated Continuous Integration server, implemented using the Microsoft .NET Framework.”</p>
<p align="right">[<a href="http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET">thoughtworks.org</a>] </p>
</blockquote>
<p>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 <a href="http://code.google.com/p/fake/downloads/list">FAKE Download page</a>.</p>
<p>If you want to know how this build script works and how you could create one for your own projects please read the <a href="http://www.navision-blog.de/2009/04/01/getting-started-with-fake-a-f-sharp-make-tool/">“Getting started with FAKE”-tutorial</a>.</p>
<p>If you want to set up “FAKE – F# Make” build configurations in TeamCity please read <a href="http://www.navision-blog.de/2009/04/15/integrate-a-fake-f-make-build-script-into-teamcity/">“Integrating a &quot;FAKE – F# Make&quot; build script into TeamCity</a>”.</p>
<h5>Installing CruiseControl.NET</h5>
<p>You can download CruiseControl.NET from <a href="http://confluence.public.thoughtworks.org/display/CCNET/Download">thoughtworks.org</a>. After the installation process (<a href="http://confluence.public.thoughtworks.org/display/CCNET/Basic+Installation">further instructions</a>) you should see an empty dashboard:</p>
<p><a href="http://www.navision-blog.de/images/IntegratingaFAKEFMakebuildscriptinto.net_7967/image.png"><img class="bordered" title="CruiseControl.NET Dashboard" border="0" alt="CruiseControl.NET Dashboard" src="http://www.navision-blog.de/images/IntegratingaFAKEFMakebuildscriptinto.net_7967/image_thumb.png" width="500" height="231" /></a> </p>
<h5>Installing Subversion</h5>
<p>The CalculatorSample is using Subversion (SVN) for <a href="http://en.wikipedia.org/wiki/Revision_control">SourceControl</a>, so we need to download SVN from <a title="http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=8100" href="http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=8100">subversion.tigris.org</a>. I’m using the “Windows MSI installer with the basic win32 binaries” and installed them under “c:\Program Files (x86)\Subversion\”.</p>
<h5>Installing FxCop</h5>
<p>The CalculatorSample is using <a href="http://msdn.microsoft.com/en-us/library/bb429476%28VS.80%29.aspx">FxCop</a>, so we need to <a href="http://www.microsoft.com/downloads/details.aspx?familyid=9AEAA970-F281-4FB0-ABA1-D59D7ED09772&amp;displaylang=en">download</a> and install it next.</p>
<blockquote><p>“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 <a href="http://go.microsoft.com/fwlink/?LinkId=70287">Design Guidelines</a> for Class Library Developers, which are the Microsoft guidelines for writing robust and easily maintainable code by using the .NET Framework.”</p>
<p align="right">[<a href="http://msdn.microsoft.com/en-us/library/bb429476%28VS.80%29.aspx">MSDN</a>]</p>
</blockquote>
<h5>Creating a FAKE Project</h5>
<p>Now create a new folder for the CalculatorSample sources. I’m using “<strong>d:\Calculator\</strong>” for the rest of the article.</p>
<p>The next step is to modify the CruiseControl.NET config file (“c:\Program Files (x86)\CruiseControl.NET\server\ccnet.config” on my machine):</p>
<div style="font-family: courier new; background: white; color: black; font-size: 7pt">
<p style="margin: 0px"><span style="color: blue">&lt;</span><span style="color: #a31515">cruisecontrol</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160; &lt;</span><span style="color: #a31515">project</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160; &lt;</span><span style="color: #a31515">name</span><span style="color: blue">&gt;</span>CalculatorExample<span style="color: blue">&lt;/</span><span style="color: #a31515">name</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160; &lt;</span><span style="color: #a31515">triggers</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">intervalTrigger</span><span style="color: blue"> </span><span style="color: red">name</span><span style="color: blue">=</span>&quot;<span style="color: blue">continuous</span>&quot;<span style="color: blue"> </span><span style="color: red">seconds</span><span style="color: blue">=</span>&quot;<span style="color: blue">30</span>&quot;<span style="color: blue"> </span><span style="color: red">initialSeconds</span><span style="color: blue">=</span>&quot;<span style="color: blue">30</span>&quot;<span style="color: blue">/&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">triggers</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160; &lt;</span><span style="color: #a31515">sourcecontrol</span><span style="color: blue"> </span><span style="color: red">type</span><span style="color: blue">=</span>&quot;<span style="color: blue">svn</span>&quot;<span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">executable</span><span style="color: blue">&gt;</span>c:\Program Files (x86)\Subversion\bin\svn.exe<span style="color: blue">&lt;/</span><span style="color: #a31515">executable</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">workingDirectory</span><span style="color: blue">&gt;</span>d:\Calculator\<span style="color: blue">&lt;/</span><span style="color: #a31515">workingDirectory</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">trunkUrl</span><span style="color: blue">&gt;</span>http://fake.googlecode.com/svn/trunk/Samples/Calculator/<span style="color: blue">&lt;/</span><span style="color: #a31515">trunkUrl</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">sourcecontrol</span><span style="color: blue">&gt;&#160;&#160;&#160; </span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160; &lt;</span><span style="color: #a31515">tasks</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">exec</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">executable</span><span style="color: blue">&gt;</span>d:\Calculator\tools\Fake\Fake.exe<span style="color: blue">&lt;/</span><span style="color: #a31515">executable</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">baseDirectory</span><span style="color: blue">&gt;</span>d:\Calculator\<span style="color: blue">&lt;/</span><span style="color: #a31515">baseDirectory</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">buildArgs</span><span style="color: blue">&gt;</span>completeBuild.fsx<span style="color: blue">&lt;/</span><span style="color: #a31515">buildArgs</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">exec</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">tasks</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160; &lt;</span><span style="color: #a31515">publishers</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">merge</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">files</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">file</span><span style="color: blue">&gt;</span>d:\Calculator\test\FXCopResults.xml<span style="color: blue">&lt;/</span><span style="color: #a31515">file</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">file</span><span style="color: blue">&gt;</span>d:\Calculator\test\TestResults.xml<span style="color: blue">&lt;/</span><span style="color: #a31515">file</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">file</span><span style="color: blue">&gt;</span>d:\Calculator\output\Results.xml<span style="color: blue">&lt;/</span><span style="color: #a31515">file</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">files</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">merge</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">xmllogger</span><span style="color: blue"> /&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">publishers</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160; &lt;/</span><span style="color: #a31515">project</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&lt;/</span><span style="color: #a31515">cruisecontrol</span><span style="color: blue">&gt;</span></p>
</p></div>
<p>In this configuration I set up a trigger which checks every 30 sec. for changes in my CalculatorSample project. </p>
<p>If SVN finds changes FAKE.exe is called with my build script (completeBuild.fsx). </p>
<p>After the build I want to merge the FxCop and NUnit output files with my build results to create a build report.</p>
<h5>Configuring the dashboard</h5>
<p>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):</p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<p style="margin: 0px"><span style="color: blue">&lt;</span><span style="color: #a31515">buildPlugins</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160; &lt;</span><span style="color: #a31515">buildReportBuildPlugin</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160; &lt;</span><span style="color: #a31515">xslFileNames</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">xslFile</span><span style="color: blue">&gt;</span>xsl\header.xsl<span style="color: blue">&lt;/</span><span style="color: #a31515">xslFile</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">xslFile</span><span style="color: blue">&gt;</span>xsl\modifications.xsl<span style="color: blue">&lt;/</span><span style="color: #a31515">xslFile</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">xslFile</span><span style="color: blue">&gt;</span>xsl\NCoverSummary.xsl<span style="color: blue">&lt;/</span><span style="color: #a31515">xslFile</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">xslFile</span><span style="color: blue">&gt;</span>xsl\fxcop-summary_1_36.xsl<span style="color: blue">&lt;/</span><span style="color: #a31515">xslFile</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">xslFile</span><span style="color: blue">&gt;</span>xsl\unittests.xsl<span style="color: blue">&lt;/</span><span style="color: #a31515">xslFile</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160; &lt;</span><span style="color: #a31515">xslFile</span><span style="color: blue">&gt;</span>xsl\nant.xsl<span style="color: blue">&lt;/</span><span style="color: #a31515">xslFile</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160; &lt;/</span><span style="color: #a31515">xslFileNames</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160; &lt;/</span><span style="color: #a31515">buildReportBuildPlugin</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160; &lt;</span><span style="color: #a31515">buildLogBuildPlugin</span><span style="color: blue"> /&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160; &lt;</span><span style="color: #a31515">xslReportBuildPlugin</span><span style="color: blue"> </span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160; </span><span style="color: red">description</span><span style="color: blue">=</span>&quot;<span style="color: blue">NCover Report</span>&quot;<span style="color: blue"> </span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160; </span><span style="color: red">actionName</span><span style="color: blue">=</span>&quot;<span style="color: blue">NCoverBuildReport</span>&quot;<span style="color: blue"> </span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160; </span><span style="color: red">xslFileName</span><span style="color: blue">=</span>&quot;<span style="color: blue">xsl\NCover.xsl</span>&quot;<span style="color: blue">&gt;&lt;/</span><span style="color: #a31515">xslReportBuildPlugin</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160; &lt;</span><span style="color: #a31515">xslReportBuildPlugin</span><span style="color: blue"> </span><span style="color: red">description</span><span style="color: blue">=</span>&quot;<span style="color: blue">FxCop Report</span>&quot;</p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160; </span><span style="color: red">actionName</span><span style="color: blue">=</span>&quot;<span style="color: blue">FxCopBuildReport</span>&quot;</p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160; </span><span style="color: red">xslFileName</span><span style="color: blue">=</span>&quot;<span style="color: blue">xsl\fxcop-report_1_36.xsl</span>&quot;<span style="color: blue"> /&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160; &lt;</span><span style="color: #a31515">xslReportBuildPlugin</span><span style="color: blue"> </span><span style="color: red">description</span><span style="color: blue">=</span>&quot;<span style="color: blue">NUnit Report</span>&quot;</p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160; </span><span style="color: red">actionName</span><span style="color: blue">=</span>&quot;<span style="color: blue">NUnitBuildReport</span>&quot;</p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160; </span><span style="color: red">xslFileName</span><span style="color: blue">=</span>&quot;<span style="color: blue">xsl\tests.xsl</span>&quot;<span style="color: blue"> /&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&lt;/</span><span style="color: #a31515">buildPlugins</span><span style="color: blue">&gt;</span></p>
</p></div>
<p>As you can see we use the nant.xsl to transform the FAKE output to HTML.</p>
<h5>Starting the build</h5>
<p>Now if everything is configured correctly, you can tell CruiseControl.NET to run your build (press “Start” for your build project on the dashboard):</p>
<p><img class="bordered" title="Press Start on the dashboard" alt="Press Start on the dashboard" src="http://www.navision-blog.de/images/IntegratingaFAKEFMakebuildscriptinto.net_7967/image_3.png" width="500" height="106" /> </p>
<p>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:</p>
<p><a href="http://www.navision-blog.de/images/IntegratingaFAKEFMakebuildscriptinto.net_7967/image_4.png"><img class="bordered" title="Build output" alt="Build output" src="http://www.navision-blog.de/images/IntegratingaFAKEFMakebuildscriptinto.net_7967/image_thumb_3.png" width="500" height="388" /></a> </p>
<p><a href="http://www.navision-blog.de/images/IntegratingaFAKEFMakebuildscriptinto.net_7967/image_5.png"><img class="bordered" title="Build output 2" border="0" alt="Build output 2" src="http://www.navision-blog.de/images/IntegratingaFAKEFMakebuildscriptinto.net_7967/image_thumb_4.png" width="500" height="388" /></a> </p>
<p>You can also inspect the NUnit and FxCop results:</p>
<p>&#160;<a href="http://www.navision-blog.de/images/IntegratingaFAKEFMakebuildscriptinto.net_7967/image_6.png"><img class="bordered" title="NUnit zest results" border="0" alt="NUnit zest results" src="http://www.navision-blog.de/images/IntegratingaFAKEFMakebuildscriptinto.net_7967/image_thumb_5.png" width="500" height="236" /></a> </p>
<p><a href="http://www.navision-blog.de/images/IntegratingaFAKEFMakebuildscriptinto.net_7967/image_7.png"><img class="bordered" title="FxCop results" border="0" alt="FxCop results" src="http://www.navision-blog.de/images/IntegratingaFAKEFMakebuildscriptinto.net_7967/image_thumb_6.png" width="500" height="249" /></a></p>
<p>Please feel free to give feedback if you have any problems with this article.</p>
<p>&copy;2012 <a href="http://www.navision-blog.de">Rash thoughts about .NET, C#, F# and Dynamics NAV.</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.navision-blog.de/2009/10/14/integrating-a-fake-f-make-build-script-into-cruisecontrol-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;FAKE &#8211; F# Make&#8221; Version 0.10 released</title>
		<link>http://www.navision-blog.de/2009/10/06/fake-fsharp_make_version_0_10_released/</link>
		<comments>http://www.navision-blog.de/2009/10/06/fake-fsharp_make_version_0_10_released/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 09:59:10 +0000</pubDate>
		<dc:creator>Steffen Forkmann</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[FAKE - F# Make]]></category>
		<category><![CDATA[F-sharp Make]]></category>
		<category><![CDATA[Fake]]></category>

		<guid isPermaLink="false">http://www.navision-blog.de/2009/10/06/fake-fsharp_make_version_0_10_released/</guid>
		<description><![CDATA[I just released a new version of my Open Source Build Automation Framework “FAKE – F# Make”. You can read more about FAKE on the project website or in the Getting started with &#34;FAKE &#8211; F# Make&#34;-article. Although the new release contains many bugfixes, I only want to show the two major improvements here. 1. [...]]]></description>
			<content:encoded><![CDATA[<p>I just released a new version of my Open Source Build Automation Framework <a href="http://code.google.com/p/fake/">“FAKE – F# Make”</a>. You can read more about FAKE on the <a href="http://code.google.com/p/fake/">project website</a> or in the <a href="http://www.navision-blog.de/2009/04/01/getting-started-with-fake-a-f-sharp-make-tool/">Getting started with &quot;FAKE &#8211; F# Make&quot;</a>-article.</p>
<p>Although the new release contains many bugfixes, I only want to show the two major improvements here.</p>
<h4>1. FAKE 0.10 uses FSI instead of FSC</h4>
<p>From now on FAKE uses the “F# Interactive” (fsi.exe) instead of the F# Compiler (fsc.exe) to run the build scripts, which brings two major improvements.</p>
<h5>No TempPath for compiled binaries needed</h5>
<p>Due to the fact that FAKE scripts are no longer compiled at the beginning of the build process, we don’t need a temporary folder for the created binaries. </p>
<h5>Loading modules at runtime</h5>
<p>The <font color="#0080ff">#load</font> command in F# scripts allows us to load modules at runtime. Now we are able to put reusable Targets or TargetTemplates (see below) into external build script files.</p>
<h4>2. TargetTemplates</h4>
<p>TargetTemplates provide an easy way to reuse common Targets. Let’s consider a (very) small sample:</p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<p style="margin: 0px">Target <span style="color: maroon">&quot;TraceHello&quot;</span> (<span style="color: blue">fun</span> () <span style="color: blue">-&gt;</span></p>
<p style="margin: 0px">&#160; trace <span style="color: maroon">&quot;Hello World from FAKE&quot;</span></p>
<p style="margin: 0px">)</p>
</p></div>
<p>This Target “TraceHello” traces a “Hello World” string into our build log. Now we want it to be slightly more generic and to trace a custom string. We can do this by using a TargetTemplate: </p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<p style="margin: 0px"><span style="color: green">/// createTraceTarget: string -&gt; string -&gt; Target</span></p>
<p style="margin: 0px"><span style="color: blue">let</span> createTraceTarget = TargetTemplate (<span style="color: blue">fun</span> s <span style="color: blue">-&gt;</span></p>
<p style="margin: 0px">&#160; trace s</p>
<p style="margin: 0px">)</p>
</p></div>
<p>Now we have a template (or a function which generates targets) that gets a string for the target name and a string for the trace text and generates&#160; a usable target:</p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<p style="margin: 0px">createTraceTarget <span style="color: maroon">&quot;TraceHello&quot;</span> <span style="color: maroon">&quot;Hello World from FAKE&quot;</span></p>
<p style="margin: 0px">createTraceTarget <span style="color: maroon">&quot;Trace2&quot;</span> <span style="color: maroon">&quot;Trace another text&quot;</span></p>
</p></div>
<p>Of course the TargetTemplate function is generic and can be used with any tuple as parameter:</p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<p style="margin: 0px"><span style="color: green">/// createTraceTarget: string -&gt; string*int -&gt; Target</span></p>
<p style="margin: 0px"><span style="color: blue">let</span> createTraceTarget = TargetTemplate (<span style="color: blue">fun</span> (s,d) <span style="color: blue">-&gt;</span></p>
<p style="margin: 0px">&#160; trace s</p>
<p style="margin: 0px">&#160; trace &lt;| sprintf <span style="color: maroon">&quot;my int: %d&quot;</span> d</p>
<p style="margin: 0px">)</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">createTraceTarget <span style="color: maroon">&quot;TraceHello&quot;</span> (<span style="color: maroon">&quot;Hello World from FAKE&quot;</span>,2)</p>
<p style="margin: 0px">createTraceTarget <span style="color: maroon">&quot;Trace2&quot;</span> (<span style="color: maroon">&quot;Trace another text&quot;</span>,42)</p>
</p></div>
<p>&copy;2012 <a href="http://www.navision-blog.de">Rash thoughts about .NET, C#, F# and Dynamics NAV.</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.navision-blog.de/2009/10/06/fake-fsharp_make_version_0_10_released/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Extensibility of functions with lambdas (in F# and C#)</title>
		<link>http://www.navision-blog.de/2009/07/01/extensibility-of-functions-with-lambdas-in-f-and-c/</link>
		<comments>http://www.navision-blog.de/2009/07/01/extensibility-of-functions-with-lambdas-in-f-and-c/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 14:02:25 +0000</pubDate>
		<dc:creator>Steffen Forkmann</dc:creator>
				<category><![CDATA[English posts]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Fake]]></category>
		<category><![CDATA[Functional Programming]]></category>

		<guid isPermaLink="false">http://www.navision-blog.de/2009/07/01/extensibility-of-functions-with-lambdas-in-f-and-c/</guid>
		<description><![CDATA[One of the nice properties of functional programming languages is the easy extensibility of custom functions. Let’s consider a simple F# function (from “FAKE – F# Make”) for a recursive directory copy: open System open System.IO /// Copies a directory recursive /// Thanks to Robert Pickering http://strangelights.com/blog/ /// param target: target directory : string /// [...]]]></description>
			<content:encoded><![CDATA[<p>One of the nice properties of functional programming languages is the easy extensibility of custom functions. Let’s consider a simple F# function (from <a href="http://code.google.com/p/fake/">“FAKE – F# Make”</a>) for a recursive directory copy:</p>
<pre class="code"><span style="color: blue">open </span>System
<span style="color: blue">open </span>System.IO
<span style="color: green">
/// Copies a directory recursive
/// Thanks to Robert Pickering <a title="http://strangelights.com/blog/" href="http://strangelights.com/blog/">http://strangelights.com/blog/</a></span><span style="color: green">
///  param target: target directory : string
///  param source: source directory : string
</span><span style="color: blue">let </span>CopyDir target source =
  Directory.GetFiles(source, <span style="color: maroon">&quot;*.*&quot;</span>, SearchOption.AllDirectories)
    |&gt; Seq.iter (<span style="color: blue">fun </span>file <span style="color: blue">-&gt;
      let </span>newFile = target + file.Remove(0, source.Length)
      printf <span style="color: maroon">&quot;%s =&gt; %s&quot; </span>file newFile
      Directory.CreateDirectory(Path.GetDirectoryName(newFile)) |&gt; ignore
      File.Copy(file, newFile, <span style="color: blue">true</span>))</pre>
<p>If we want to allow users to set custom file filters, we can add a third parameter:</p>
<pre class="code"><span style="color: green">/// Copies a directory recursive
<strong>/// and allows to filter the files</strong>
<span style="color: green">/// Thanks to Robert Pickering <a title="http://strangelights.com/blog/" href="http://strangelights.com/blog/">http://strangelights.com/blog/</span></span><span style="color: green"></span></a>
<span style="color: green">///  param target: target directory : string
///  param source: source directory : string
<strong>///  param filterFile: FilterFunction: string -&gt; bool</strong>
</span><span style="color: blue">let </span>CopyDirFiltered target source <strong>filterFile</strong> =
  Directory.GetFiles(source, <span style="color: maroon">&quot;*.*&quot;</span>, SearchOption.AllDirectories)
    <strong>|&gt; Seq.filter filterFile</strong>
    |&gt; Seq.iter (<span style="color: blue">fun </span>file <span style="color: blue">-&gt;
      let </span>newFile = target + file.Remove(0, source.Length)
      printfn <span style="color: maroon">&quot;%s =&gt; %s&quot; </span>file newFile
      Directory.CreateDirectory(Path.GetDirectoryName(newFile)) |&gt; ignore
      File.Copy(file, newFile, <span style="color: blue">true</span>))</pre>
<p>Now we can define some filter functions:</p>
<pre class="code"><span style="color: green">/// Exclude SVN files (path with .svn)
/// excludeSVNFiles<strong>: string -&gt; bool</strong>
</span><span style="color: blue">let </span>excludeSVNFiles (path:string) = not &lt;| path.Contains <span style="color: maroon">&quot;.svn&quot;

</span><span style="color: green">/// Includes all files
/// allFiles<strong>: string -&gt; bool</strong> </span>
</span><span style="color: blue">let </span>allFiles (path:string) = <span style="color: blue">true</span></pre>
<p>Now it is possible to use CopyDirFiltered in the following ways:</p>
<pre class="code"><span style="color: green">/// Copies all files &lt;=&gt; same as CopyDir
</span>CopyDirFiltered <span style="color: maroon">&quot;C:\\target&quot; &quot;C:\\source&quot; </span>allFiles

<span style="color: green">/// Copies all files except SVN files
</span>CopyDirFiltered <span style="color: maroon">&quot;C:\\target&quot; &quot;C:\\source&quot; </span>excludeSVNFiles

<span style="color: green">/// Copies all files only if random number &lt;&gt; 2
</span><span style="color: blue">let </span>r = <span style="color: blue">new </span>Random()
CopyDirFiltered <span style="color: maroon">&quot;C:\\target&quot; &quot;C:\\source&quot; </span>(<span style="color: blue">fun </span>path <span style="color: blue">-&gt; </span>r.Next(5) &lt;&gt; 2)</pre>
<h5>Extensibility of functions in C#</h5>
<p>Of course we can do the same thing in C# 3.0:</p>
<pre class="code"><span style="color: gray">/// &lt;summary&gt;
/// </span><span style="color: green">Copies a directory recursive
</span><span style="color: gray">/// </span><span style="color: green">and allows to filter the files
</span><span style="color: gray">/// &lt;/summary&gt;
/// &lt;param name=&quot;target&quot;&gt;</span><span style="color: green">The target.</span><span style="color: gray">&lt;/param&gt;
/// &lt;param name=&quot;source&quot;&gt;</span><span style="color: green">The source.</span><span style="color: gray">&lt;/param&gt;
/// &lt;param name=&quot;fileFilter&quot;&gt;</span><span style="color: green">The file filter.</span><span style="color: gray">&lt;/param&gt;
</span><span style="color: blue">public static void </span>CopyDirFiltered(<span style="color: blue">string </span>target, <span style="color: blue">string </span>source,
                                   <span style="color: #2b91af">Func</span>&lt;<span style="color: blue">string</span>, <span style="color: blue">bool</span>&gt; fileFilter)
{
    <span style="color: blue">string</span>[] allFiles = <span style="color: #2b91af">Directory</span>.GetFiles(
        source, <span style="color: #a31515">&quot;*.*&quot;</span>, <span style="color: #2b91af">SearchOption</span>.AllDirectories);
    <span style="color: blue">foreach </span>(<span style="color: blue">string </span>file <span style="color: blue">in from </span>f <span style="color: blue">in </span>allFiles
                            <span style="color: blue">where </span>fileFilter(f)
                            <span style="color: blue">select </span>f)
    {
        <span style="color: blue">string </span>newFile = target + file.Remove(0, source.Length);
        <span style="color: #2b91af">Console</span>.WriteLine(<span style="color: #a31515">&quot;{0} =&gt; {1}&quot;</span>, file, newFile);
        <span style="color: #2b91af">Directory</span>.CreateDirectory(<span style="color: #2b91af">Path</span>.GetDirectoryName(newFile));
        <span style="color: #2b91af">File</span>.Copy(file, newFile, <span style="color: blue">true</span>);
    }
}</pre>
<p>Now it is easy to use the C# function with lambdas:</p>
<blockquote>
<p>“A lambda expression is an anonymous function that can contain expressions and statements, and can be used to create delegates or expression tree types.”</p>
<p align="right">[<a href="http://msdn.microsoft.com/en-us/library/bb397687.aspx">MSDN</a>]</p>
</blockquote>
<pre class="code"><span style="color: #2b91af">Func</span>&lt;<span style="color: blue">string</span>, <span style="color: blue">bool</span>&gt; filterSVN = x =&gt; !x.Contains(<span style="color: #a31515">&quot;.svn&quot;</span>);
<span style="color: #2b91af">Func</span>&lt;<span style="color: blue">string</span>, <span style="color: blue">bool</span>&gt; allFiles = x =&gt; <span style="color: blue">true</span>;

<span style="color: gray">/// </span><span style="color: green">Copies all files </span><span style="color: gray">&lt;=&gt; </span><span style="color: green">same as CopyDir
</span>CopyDirFiltered(<span style="color: #a31515">&quot;C:\\target&quot;</span>, <span style="color: #a31515">&quot;C:\\source&quot;</span>, allFiles);

<span style="color: gray">/// </span><span style="color: green">Copies all files except SVN files
</span>CopyDirFiltered(<span style="color: #a31515">&quot;C:\\target&quot;</span>, <span style="color: #a31515">&quot;C:\\source&quot;</span>, filterSVN);

<span style="color: gray">/// </span><span style="color: green">Copies all files only if random number </span><span style="color: gray">&lt;&gt; </span><span style="color: green">2
</span><span style="color: blue">var </span>r = <span style="color: blue">new </span><span style="color: #2b91af">Random</span>();
CopyDirFiltered(<span style="color: #a31515">&quot;C:\\target&quot;</span>, <span style="color: #a31515">&quot;C:\\source&quot;</span>, path =&gt; r.Next(5) != 2);</pre>
<p>Keeping this simple technique in mind allows to create very flexible functions.</p>
<p>&copy;2012 <a href="http://www.navision-blog.de">Rash thoughts about .NET, C#, F# and Dynamics NAV.</a>. All Rights Reserved.</p>.]]></content:encoded>
			<wfw:commentRss>http://www.navision-blog.de/2009/07/01/extensibility-of-functions-with-lambdas-in-f-and-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

