<?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; MSBuild</title>
	<atom:link href="http://www.navision-blog.de/tag/msbuild/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>Wed, 14 Jul 2010 11:12:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Writing custom tasks for &#8220;FAKE &#8211; F# Make&#8221;</title>
		<link>http://www.navision-blog.de/2009/04/14/writing-custom-tasks-for-fake-f-make/</link>
		<comments>http://www.navision-blog.de/2009/04/14/writing-custom-tasks-for-fake-f-make/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 13:37:48 +0000</pubDate>
		<dc:creator>Steffen Forkmann</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[FAKE - F# Make]]></category>
		<category><![CDATA[F-sharp Make]]></category>
		<category><![CDATA[Fake]]></category>
		<category><![CDATA[MSBuild]]></category>
		<category><![CDATA[NAnt]]></category>

		<guid isPermaLink="false">http://www.navision-blog.de/2009/04/14/writing-custom-tasks-for-fake-f-make/</guid>
		<description><![CDATA[“FAKE – F# Make” is intended to be an extensible build framework. That’s why I tried to make it as easy as possible to create custom tasks. This posts shows how we can create a (very simple) custom task in C# which gives a random number. First of all open Visual Studio and create a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://code.google.com/p/fake/">“FAKE – F# Make”</a> is intended to be an extensible build framework. That’s why I tried to make it as easy as possible to create custom tasks. This posts shows how we can create a (very simple) custom task in C# which gives a random number.</p>
<p>First of all open Visual Studio and create a new C# class library called my MyCustomTask and create a class called RandomNumberTask:</p>
<pre class="code"><span style="color: blue">using </span>System;

<span style="color: blue">namespace </span>MyCustomTask
{
    <span style="color: blue">public class </span><span style="color: #2b91af">RandomNumberTask
    </span>{
        <span style="color: blue">public static int </span>RandomNumber(<span style="color: blue">int </span>min, <span style="color: blue">int </span>max)
        {
            <span style="color: blue">var </span>random = <span style="color: blue">new </span><span style="color: #2b91af">Random</span>();
            <span style="color: blue">return </span>random.Next(min, max);
        }
    }
}</pre>
<p>Now compile this project and put the resulting assembly and debug symbols into the <em>tools/FAKE</em> path of your project. Now you can use your CustomTask in the build script:</p>
<pre class="code"><span style="color: blue">#light
</span><span style="color: green">// include Fake libs
</span><span style="color: blue">#I </span><span style="color: maroon">&quot;tools\FAKE&quot;
</span><span style="color: blue">#r </span><span style="color: maroon">&quot;FakeLib.dll&quot;

</span><span style="color: green">// include CustomTask
</span><span style="color: blue">#r </span><span style="color: maroon">&quot;MyCustomTask.dll&quot;
</span><span style="color: blue">open </span>Fake 

<span style="color: green">// open CustomNamespace
</span><span style="color: blue">open </span>MyCustomTask

<span style="color: green">// use custom functionality
</span><span style="color: blue">let </span>x = RandomNumberTask.RandomNumber(2,13)
sprintf <span style="color: maroon">&quot;RandomNumber: %d&quot; </span>x |&gt; trace</pre>
<p><img class="bordered" title="Using custom tasks in FAKE" alt="Using custom tasks in FAKE" src="http://www.navision-blog.de/images/WritingcustomtasksforFAKEFMake_D6DE/image.png" width="500" height="142" /> </p>
<p>You can use every .Net class with FAKE. Just put the assembly in the right folder <em>(tools/FAKE</em>) and include it with the #r command. </p>
<p>If you want to use FAKE standard functionality (like <a href="http://en.wikipedia.org/wiki/Glob_(programming)">globbing</a>) within your CustomTask project, just reference FakeLib.dll and explore the FAKE namespace.</p>
<p>&copy;2010 <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/04/14/writing-custom-tasks-for-fake-f-make/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging &#8220;FAKE &#8211; F# Make&#8221; build scripts</title>
		<link>http://www.navision-blog.de/2009/04/05/debugging-fake-f-make-build-scripts/</link>
		<comments>http://www.navision-blog.de/2009/04/05/debugging-fake-f-make-build-scripts/#comments</comments>
		<pubDate>Sun, 05 Apr 2009 17:08:33 +0000</pubDate>
		<dc:creator>Steffen Forkmann</dc:creator>
				<category><![CDATA[F#]]></category>
		<category><![CDATA[FAKE - F# Make]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Debugging build scripts]]></category>
		<category><![CDATA[F-sharp Make]]></category>
		<category><![CDATA[MSBuild]]></category>

		<guid isPermaLink="false">http://www.navision-blog.de/2009/04/05/debugging-fake-f-make-build-scripts/</guid>
		<description><![CDATA[This post addresses the No. 1 Feature request for MSBuild: Debugging. With FAKE builds scripts debugging is no issue. Just write System.Diagnostics.Debugger.Break() somewhere into your build script and start the build. It is nearly as easy as pressing F9 in Visual Studio. If the build script reaches your Breakpoint it will ask you which Debugger [...]]]></description>
			<content:encoded><![CDATA[<p>This post addresses the <a href="http://blogs.msdn.com/msbuild/archive/2007/11/30/response-to-the-feature-poll.aspx">No. 1 Feature request for MSBuild: Debugging</a>. </p>
<p>With <a href="http://code.google.com/p/fake/">FAKE builds scripts</a> debugging is no issue. Just write <strong>System.Diagnostics.Debugger.Break() </strong>somewhere into your build script and start the build. It is nearly as easy as pressing F9 in Visual Studio. </p>
<p>If the build script reaches your Breakpoint it will ask you which Debugger you want to use:</p>
<p><img style="display: inline" title="Just in time debugger with FAKE" alt="Just in time debugger with FAKE" src="http://www.navision-blog.de/images/DebuggingFAKEFMakebuildscripts_10D11/image.png" width="300" height="324" />&#160;</p>
<p>If you are editing your build script in Visual Studio you can select that instance otherwise choose a new instance and you are ready to debug:</p>
<p><img style="display: inline" title="image" alt="image" src="http://www.navision-blog.de/images/DebuggingFAKEFMakebuildscripts_10D11/image_3.png" width="381" height="124" /></p>
<p>&copy;2010 <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/04/05/debugging-fake-f-make-build-scripts/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Modifying AssemblyInfo and Version via FAKE &#8211; F# Make</title>
		<link>http://www.navision-blog.de/2009/04/04/modifying-assemblyinfo-and-version-via-fake-f-make/</link>
		<comments>http://www.navision-blog.de/2009/04/04/modifying-assemblyinfo-and-version-via-fake-f-make/#comments</comments>
		<pubDate>Sat, 04 Apr 2009 12:54:02 +0000</pubDate>
		<dc:creator>Steffen Forkmann</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[FAKE - F# Make]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[assemblyinfo]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[F-sharp Make]]></category>
		<category><![CDATA[MSBuild]]></category>
		<category><![CDATA[NAnt]]></category>
		<category><![CDATA[TeamCity]]></category>

		<guid isPermaLink="false">http://www.navision-blog.de/2009/04/04/modifying-assemblyinfo-and-version-via-fake-f-make/</guid>
		<description><![CDATA[In the last two articles I showed how we can set up FAKE to make an automated build and how we can use it with FxCop. This time we will use FAKE’s AssemblyInfo task in order to set a specific version info to our assemblies. I assume you have succeeded the CaculatorSample tutorial. If so [...]]]></description>
			<content:encoded><![CDATA[<p>In the last two articles I showed how we can <a href="http://www.navision-blog.de/2009/04/01/getting-started-with-fake-a-f-sharp-make-tool/">set up FAKE to make an automated build</a> and how we can <a href="http://www.navision-blog.de/2009/04/02/adding-fxcop-to-a-fake-build-script/">use it with FxCop</a>. This time we will use <a href="http://code.google.com/p/fake/">FAKE</a>’s AssemblyInfo task in order to set a specific version info to our assemblies.</p>
<p>I assume you have succeeded the <a href="http://www.navision-blog.de/2009/04/01/getting-started-with-fake-a-f-sharp-make-tool/">CaculatorSample tutorial</a>. If so then just modify your “Build” target to the following:</p>
<pre class="code">Target <span style="color: maroon">&quot;BuildApp&quot; </span>(<span style="color: blue">fun </span>() <span style="color: blue">-&gt;
<strong>  </strong></span><strong>AssemblyInfo
    (<span style="color: blue">fun </span>p </strong><strong><span style="color: blue">-&gt;
      </span>{p </strong><strong><span style="color: blue">with
        </span>CodeLanguage = CSharp;
        AssemblyVersion = version;
        AssemblyTitle = <span style="color: maroon">&quot;Calculator Command line tool&quot;</span>;
        AssemblyDescription = <span style="color: maroon">&quot;Sample project for FAKE - F# MAKE&quot;</span>;
        Guid = <span style="color: maroon">&quot;A539B42C-CB9F-4a23-8E57-AF4E7CEE5BAA&quot;</span>;
        OutputFileName = <span style="color: maroon">@&quot;.\src\app\Calculator\Properties\AssemblyInfo.cs&quot;</span>})

  AssemblyInfo
    (<span style="color: blue">fun </span>p </strong><strong><span style="color: blue">-&gt;
      </span>{p </strong><strong><span style="color: blue">with
        </span>CodeLanguage = CSharp;
        AssemblyVersion = version;
        AssemblyTitle = <span style="color: maroon">&quot;Calculator library&quot;</span>;
        AssemblyDescription = <span style="color: maroon">&quot;Sample project for FAKE - F# MAKE&quot;</span>;
        Guid = <span style="color: maroon">&quot;EE5621DB-B86B-44eb-987F-9C94BCC98441&quot;</span>;
        OutputFileName = <span style="color: maroon">@&quot;.\src\app\CalculatorLib\Properties\AssemblyInfo.cs&quot;</span>})</strong>          

  <span style="color: blue">let </span>target = <span style="color: maroon">&quot;Build&quot;
  </span><span style="color: green">// compile all projects below src\app\
  </span><span style="color: blue">let </span>apps = MSBuild buildDir target appReferences
  <span style="color: green">// log the output files
  </span>Log <span style="color: maroon">&quot;AppBuild-Output: &quot; </span>apps
)</pre>
<p>As you can see modifying your AssemblyInfo.cs file is pretty easy with <a href="http://code.google.com/p/fake/">FAKE</a>. The AssemblyInfo task <strong>works for C#, VB.Net and F#.</strong> The version parameter can be declared as a property or fetched from a build server like <a href="http://www.jetbrains.com/teamcity/">TeamCity</a>:</p>
<pre class="code"><span style="color: blue">let </span>version =
  <span style="color: blue">let </span>no = System.Environment.GetEnvironmentVariable(<span style="color: maroon">&quot;BUILD_NUMBER&quot;</span>)
  <span style="color: blue">if </span>no &lt;&gt; <span style="color: maroon">&quot;&quot; </span>&amp;&amp; no &lt;&gt; <span style="color: blue">null then </span>no <span style="color: blue">else </span><span style="color: maroon">&quot;0.2&quot;</span></pre>
<p><img class="bordered" title="AssemblyInfo" alt="AssemblyInfo" src="http://www.navision-blog.de/images/ModifyingAssemblyInfoandVersionviaFAKEFM_D173/image.png" width="242" height="329" /></p>
<p>&copy;2010 <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/04/04/modifying-assemblyinfo-and-version-via-fake-f-make/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Adding FxCop to a &#8220;FAKE&#8221; build script</title>
		<link>http://www.navision-blog.de/2009/04/02/adding-fxcop-to-a-fake-build-script/</link>
		<comments>http://www.navision-blog.de/2009/04/02/adding-fxcop-to-a-fake-build-script/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 16:19:03 +0000</pubDate>
		<dc:creator>Steffen Forkmann</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[English posts]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[FAKE - F# Make]]></category>
		<category><![CDATA[NaturalSpec]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Code Quality]]></category>
		<category><![CDATA[F-sharp Make]]></category>
		<category><![CDATA[Fake]]></category>
		<category><![CDATA[FxCop]]></category>
		<category><![CDATA[MSBuild]]></category>
		<category><![CDATA[NAnt]]></category>

		<guid isPermaLink="false">http://www.navision-blog.de/2009/04/02/adding-fxcop-to-a-fake-build-script/</guid>
		<description><![CDATA[In the last article I showed how we can use “FAKE – F# Make” to set up a build script which Cleans up old build outputs Compiles our main projects Compiles test projects Uses NUnit to test our assemblies Zips the assemblies to a deploy folder. This time we will improve the same Calculator sample [...]]]></description>
			<content:encoded><![CDATA[<p>In the <a href="http://www.navision-blog.de/2009/04/01/getting-started-with-fake-a-f-sharp-make-tool/">last article</a> I showed how we can use “<a href="http://code.google.com/p/fake/">FAKE – F# Make</a>” to set up a build script which</p>
<ol>
<li>Cleans up old build outputs </li>
<li>Compiles our main projects </li>
<li>Compiles test projects </li>
<li>Uses NUnit to test our assemblies </li>
<li>Zips the assemblies to a deploy folder. </li>
</ol>
<p>This time we will improve the same Calculator sample (<a href="http://code.google.com/p/fake/downloads/list">download here</a>) with a task for <a href="http://msdn2.microsoft.com/en-us/library/bb429476.aspx">FxCop</a>, so please make sure you succeeded with the last article.</p>
<blockquote><p><b>“FxCop</b> is a free <a href="http://en.wikipedia.org/wiki/Static_code_analysis">static code analysis</a> tool from <a href="http://en.wikipedia.org/wiki/Microsoft">Microsoft</a> that checks <a href="http://en.wikipedia.org/wiki/.NET_Framework">.NET</a> <a href="http://en.wikipedia.org/wiki/Managed_code">managed code</a> <a href="http://en.wikipedia.org/wiki/.NET_assembly">assemblies</a> for conformance to Microsoft&#8217;s .NET Framework Design Guidelines.”</p>
<p align="right">[<a href="http://en.wikipedia.org/wiki/FxCop">Wikipedia</a>]</p>
</blockquote>
<h5>Setting up FxCop</h5>
<p>First of all you have to <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=9aeaa970-f281-4fb0-aba1-d59d7ed09772&amp;DisplayLang=en">download</a> and install FxCop. Now open <em>build.fsx</em> from you Calculator sample folder and add a new target “FxCop” to the targets section:</p>
<pre class="code">Target <span style="color: maroon">&quot;FxCop&quot; </span>(<span style="color: blue">fun </span>() <span style="color: blue">-&gt;
  let </span>assemblies =
    !+ (buildDir + <span style="color: maroon">@&quot;\**\*.dll&quot;</span>)
      ++ (buildDir + <span style="color: maroon">@&quot;\**\*.exe&quot;</span>)
      |&gt; Scan
  FxCop
    (<span style="color: blue">fun </span>p <span style="color: blue">-&gt;
      </span>{p <span style="color: blue">with
        </span><span style="color: green">// override default parameters
        </span>ReportFileName = testDir + <span style="color: maroon">&quot;FXCopResults.xml&quot;</span>;
        ToolPath = <span style="color: maroon">@&quot;c:\Program Files (x86)\Microsoft FxCop 1.36\&quot;</span>})
    assemblies
)</pre>
<p>In the dependencies section modify the dependencies of the “Test” targets:</p>
<pre class="code"><span style="color: maroon">&quot;Test&quot; </span>&lt;== [<span style="color: maroon">&quot;BuildApp&quot;</span>; <span style="color: maroon">&quot;BuildTest&quot;</span>; <span style="color: maroon">&quot;FxCop&quot;</span>]</pre>
<p>That’s it. If you run your build script you will get new *.xml file in the .\test\-folder:</p>
<p><img class="bordered" title="FxCop result viewed with Internet Explorer 8" alt="FxCop result viewed with Internet Explorer 8" src="http://www.navision-blog.de/images/AddingFXCoptoaFAKEbuildscript_FFDA/image.png" width="500" height="428" /></p>
<p>There are a lot of parameters for the <a href="http://code.google.com/p/fake/wiki/FxCop">FxCop task</a>. Some are described on the <a href="http://code.google.com/p/fake/wiki/FxCop">project page</a>.</p>
<h5>Letting the build fail</h5>
<p>If you were using MSBuild before you might know how hard it is to <a href="http://blogs.conchango.com/johnrayner/archive/2006/10/05/Getting-FxCop-to-break-the-build.aspx">let MSBuild fail your build if FxCop reports any errors</a> or warnings.</p>
<p>With FAKE the only thing you have to do is setting the “FailOnError” parameter:</p>
<pre class="code">Target <span style="color: maroon">&quot;FxCop&quot; </span>(<span style="color: blue">fun </span>() <span style="color: blue">-&gt;
  let </span>assemblies =
    !+ (buildDir + <span style="color: maroon">@&quot;\**\*.dll&quot;</span>)
      ++ (buildDir + <span style="color: maroon">@&quot;\**\*.exe&quot;</span>)
      |&gt; Scan  

  FxCop
    (<span style="color: blue">fun </span>p <span style="color: blue">-&gt;
      </span>{p <span style="color: blue">with
        </span><span style="color: green">// override default parameters
        </span>ReportFileName = testDir + <span style="color: maroon">&quot;FXCopResults.xml&quot;</span>;
        <strong>FailOnError = FxCopyErrorLevel.CriticalWarning;</strong>
        ToolPath = fxCopPath})
    assemblies
)</pre>
<p><img class="bordered" title="Letting the build fail" alt="Letting the build fail" src="http://www.navision-blog.de/images/AddingFXCoptoaFAKEbuildscript_FFDA/image_3.png" width="307" height="207" /> </p>
<p>If you activate this option <a href="http://code.google.com/p/fake/wiki/FxCop">FxCop</a> errors will cause your build to fail. Possible values are: </p>
<ul>
<li>FxCopyErrorLevel.Warning </li>
<li>FxCopyErrorLevel.CriticalWarning </li>
<li>FxCopyErrorLevel.Error </li>
<li>FxCopyErrorLevel.CriticalError </li>
<li>FxCopyErrorLevel.ToolError </li>
<li>FxCopyErrorLevel.DontFailBuild </li>
</ul>
<p>The values are cummulative. If you choose FxCopyErrorLevel.CriticalWarning the build will fail for critical warnings, errors, critical errors and <a href="http://code.google.com/p/fake/wiki/FxCop">FxCop</a> tool errors but not for simple warnings. The default is FxCopyErrorLevel.DontFailBuild.</p>
<p>&copy;2010 <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/04/02/adding-fxcop-to-a-fake-build-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting started with &#8220;FAKE &#8211; F# Make&#8221; &#8211; Get rid of the noise in your build scripts.</title>
		<link>http://www.navision-blog.de/2009/04/01/getting-started-with-fake-a-f-sharp-make-tool/</link>
		<comments>http://www.navision-blog.de/2009/04/01/getting-started-with-fake-a-f-sharp-make-tool/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 19:02:30 +0000</pubDate>
		<dc:creator>Steffen Forkmann</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[English posts]]></category>
		<category><![CDATA[F#]]></category>
		<category><![CDATA[FAKE - F# Make]]></category>
		<category><![CDATA[Informatik]]></category>
		<category><![CDATA[NaturalSpec]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[F-sharp Make]]></category>
		<category><![CDATA[Fake]]></category>
		<category><![CDATA[MSBuild]]></category>
		<category><![CDATA[NAnt]]></category>
		<category><![CDATA[Rake]]></category>

		<guid isPermaLink="false">http://www.navision-blog.de/2009/04/01/getting-started-with-fake-a-f-sharp-make-tool/</guid>
		<description><![CDATA[In this tutorial I will describe how you can set up a complete build infrastructure with “FAKE – F# Make”. You will learn: How to automatically compile your C# or F# projects How to automatically run NUnit UnitTests on your projects How to zip the output to a deployment folder Install F# “FAKE – F# [...]]]></description>
			<content:encoded><![CDATA[<p>In this tutorial I will describe how you can set up a complete build infrastructure with “<a href="http://code.google.com/p/fake/">FAKE – F# Make</a>”. You will learn:</p>
<ul>
<li>How to automatically compile your C# or F# projects </li>
<li>How to automatically run <a href="http://www.nunit.org/index.php?p=home">NUnit</a> UnitTests on your projects </li>
<li>How to zip the output to a deployment folder </li>
</ul>
<h5>Install F#</h5>
<p>“FAKE – F# Make” is completely written in <a href="http://en.wikipedia.org/wiki/F_Sharp_programming_language">F#</a> and all build scripts will also be written in F#, but this doesn’t imply you have to learn programming in F#. In fact the “FAKE – F# Make” syntax is very easy to learn. But if you need to you can use the complete power of F# and the .NET Framework.</p>
<p>But in order to get things working we need to install the F# environment. You can download the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=444005fb-e627-4feb-b51d-13d6a3b4b8ed&amp;displaylang=en">F# April 2010 CTP</a> from the <a href="http://msdn.microsoft.com/en-us/fsharp/default.aspx">Microsoft F# Developer Center</a> or install Visual Studio 2010.</p>
<h5>Download Calculator Sample</h5>
<p>Now download the latest CalculatorSample-*.zip from the <a title="http://code.google.com/p/fake/downloads/list" href="http://bitbucket.org/forki/fake/downloads/">FAKE Download site</a>. This sample includes 3 tiny projects and basically the following structure:</p>
<ul>
<li>src\app
<ul>
<li>Calculator (Command line) </li>
<li>CalculatorLib (Class library) </li>
</ul>
</li>
<li>src\test
<ul>
<li>Test.CalculatorLib (NUnit test library) </li>
</ul>
</li>
<li>tools
<ul>
<li>FAKE Assemblies </li>
<li>NUnit </li>
</ul>
</li>
<li>build.bat </li>
<li>build.fsx </li>
<li>completeBuild.bat </li>
<li>completeBuild.fsx </li>
<li>Calculator.sln </li>
</ul>
<h5>Getting “FAKE – F# Make” started</h5>
<p>Open the file <em>tools\FAKE\FakeLib.dll.config</em> and check if the default configuration matches your system environment:</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">xml</span><span style="color: blue"> </span><span style="color: red">version</span><span style="color: blue">=</span>&quot;<span style="color: blue">1.0</span>&quot;<span style="color: blue"> </span><span style="color: red">encoding</span><span style="color: blue">=</span>&quot;<span style="color: blue">utf-8</span>&quot;<span style="color: blue">?&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&lt;</span><span style="color: #a31515">configuration</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160; &lt;</span><span style="color: #a31515">appSettings</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">add</span><span style="color: blue"> </span><span style="color: red">key</span><span style="color: blue">=</span>&quot;<span style="color: blue">MSBuildPath</span>&quot;<span style="color: blue"> </span></p>
<p style="margin: 0px"><span style="color: blue">&#160;&#160;&#160;&#160;&#160; </span><span style="color: red">value</span><span style="color: blue">=</span>&quot;<span style="color: blue">c:\Windows\Microsoft.NET\Framework\v4.0.30319\</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">add</span><span style="color: blue"> </span><span style="color: red">key</span><span style="color: blue">=</span>&quot;<span style="color: blue">FSIPath</span>&quot;<span style="color: blue"> </span></p>
<p style="margin: 0px"><span style="color: blue"></span><span style="color: red">&#160;&#160;&#160;&#160;&#160; value</span><span style="color: blue">=</span>&quot;<span style="color: blue">[ProgramFiles]\FSharp-2.0.0.0\bin\</span>&quot;<span style="color: blue"> /&gt;</span></p>
<p style="margin: 0px"><span style="color: blue">&#160; &lt;/</span><span style="color: #a31515">appSettings</span><span style="color: blue">&gt;</span></p>
<p style="margin: 0px">
<p style="margin: 0px"><span style="color: blue"></span></p>
<p>     <span style="color: blue">&lt;/</span><span style="color: #a31515">configuration</span><span style="color: blue">&gt;</span></p>
</p></div>
<p>If you run the build.bat from the command line then your first FAKE script (build.fsx) will be executed. If everything works fine you will get the following output:</p>
<p><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" class="bordered" title="Hello World from FAKE" border="0" alt="Hello World from FAKE" src="http://www.navision-blog.de/images/GettingstartedwithFAKEFMake_C1BC/image.png" width="500" height="185" /></p>
<p>Now open the <em>build.fsx</em> with Visual Studio. It should look like this:</p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<p style="margin: 0px"><span style="color: green">// include Fake libs</span></p>
<p style="margin: 0px"><span style="color: blue">#I</span> <span style="color: maroon">@&quot;tools\FAKE&quot;</span></p>
<p style="margin: 0px"><span style="color: blue">#r</span> <span style="color: maroon">&quot;FakeLib.dll&quot;</span></p>
<p style="margin: 0px"><span style="color: blue">open</span> Fake</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: green">// Default target</span></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"><span style="color: green">// start build</span></p>
<p style="margin: 0px">Run? Default</p>
</p></div>
<p>As you can see the code is really simple. The very first lines include the FAKE libraries and are vital in all FAKE build scripts.</p>
<p>After this header the <em>Default</em> target is defined. A target definition contains of two important parts. The first is the name of the target (here “Default”) and the second is an action (here a simple trace of “Hello world”). Action can be defined as lambda expressions or methods.</p>
<p>The last line runs the “Default” target &#8211; which means it executes the defined action.</p>
<h5>Cleaning the last build output</h5>
<p>A typical first step in nearly every build scenario is to clean the output of the last build. We can achieve this by modifying the <em>build.fsx</em> to the following:</p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<p style="margin: 0px"><span style="color: green">// include Fake libs</span></p>
<p style="margin: 0px"><span style="color: blue">#I</span> <span style="color: maroon">@&quot;tools\FAKE&quot;</span></p>
<p style="margin: 0px"><span style="color: blue">#r</span> <span style="color: maroon">&quot;FakeLib.dll&quot;</span></p>
<p style="margin: 0px"><span style="color: blue">open</span> Fake</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: green">// Properties</span></p>
<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: green">// Targets</span></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"><span style="color: green">// Dependencies</span></p>
<p style="margin: 0px">For? Default &lt;- Dependency? Clean</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: green">// start build</span></p>
<p style="margin: 0px">Run? Default</p>
</p></div>
<p>We introduced some new concepts in this snippet. At first we defined a global property called “buildDir” with the relative path of a temporary build folder.</p>
<p>In the <em>Clean</em> target we want the CleanDir task to clean up this build directory. This simply deletes all files in the folder or creates the directory if necessary.</p>
<p>In the dependencies section we say that the Default target is dependent of the Clean target. In other words Clean is a prerequisite of Default and will be run before the execution of Default:</p>
<p><a href="http://www.navision-blog.de/images/GettingstartedwithFAKEFMakeGetridofthen_10682/image.png"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" class="bordered" title="Clean is a dependency of Default" border="0" alt="Clean is a dependency of Default" src="http://www.navision-blog.de/images/GettingstartedwithFAKEFMakeGetridofthen_10682/image_thumb.png" width="378" height="185" /></a>&#160;</p>
<h5>Building the application</h5>
<p>In the next step we want to compile our application libraries, which means we want to compile all projects under /src/app with MSBuild.</p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<p style="margin: 0px"><span style="color: green">// include Fake libs</span></p>
<p style="margin: 0px"><span style="color: blue">#I</span> <span style="color: maroon">@&quot;tools\FAKE&quot;</span></p>
<p style="margin: 0px"><span style="color: blue">#r</span> <span style="color: maroon">&quot;FakeLib.dll&quot;</span></p>
<p style="margin: 0px"><span style="color: blue">open</span> Fake</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: green">// Properties</span></p>
<p style="margin: 0px"><span style="color: blue">let</span> buildDir = <span style="color: maroon">@&quot;.\build\&quot;</span></p>
<p style="margin: 0px"><span style="color: blue">let</span> appReferences = Scan (!+ <span style="color: maroon">@&quot;src\app\**\*.csproj&quot;</span>)</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: green">// Targets</span></p>
<p style="margin: 0px">Target? Clean &lt;-</p>
<p style="margin: 0px">&#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? BuildApp &lt;-</p>
<p style="margin: 0px">&#160; <span style="color: blue">fun</span> _ <span style="color: blue">-&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">let</span> target = <span style="color: maroon">&quot;Build&quot;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: green">// compile all projects below src/app/ in Release mode</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">let</span> apps = MSBuildRelease buildDir target appReferences</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: green">// log the output files</span></p>
<p style="margin: 0px">&#160;&#160;&#160; Log <span style="color: maroon">&quot;AppBuild-Output: &quot;</span> apps</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">Target? Default &lt;-</p>
<p style="margin: 0px">&#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"><span style="color: green">// Dependencies</span></p>
<p style="margin: 0px">For? BuildApp &lt;- Dependency? Clean</p>
<p style="margin: 0px">For? Default &lt;- Dependency? BuildApp</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: green">// start build</span></p>
<p style="margin: 0px">Run? Default</p>
</p></div>
<p>Again, we defined a new build target named “BuildApp” which compiles all project files given in the property appReferences with the MSBuild task. The output will be copied to <em>buildDir</em>.</p>
<p>In order to find the right project files “FAKE – F# Make” scans the folder src/app/ and all subfolders with the given pattern. Therefore a similar FileSet definition like in NAnt or MSBuild (see <a href="http://code.google.com/p/fake/">project page</a> for details) is used.</p>
<p>In addition the target dependencies are modified. Now Default is dependent of BuildApp and BuildApp needs Clean as a prerequisite.</p>
<p>This means the execution order is: Clean ==&gt; BuildApp ==&gt; Default.</p>
<p><a href="http://www.navision-blog.de/images/GettingstartedwithFAKEFMakeGetridofthen_10682/image_3.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="App-Build output" border="0" alt="App-Build output" src="http://www.navision-blog.de/images/GettingstartedwithFAKEFMakeGetridofthen_10682/image_thumb_3.png" width="470" height="222" /></a>&#160;</p>
<h5>Building Test projects</h5>
<p>Now our main application will be built automatically and it’s time to build the test application. We use pretty the same concepts as before:</p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<p style="margin: 0px"><span style="color: green">// include Fake libs</span></p>
<p style="margin: 0px"><span style="color: blue">#I</span> <span style="color: maroon">@&quot;tools\FAKE&quot;</span></p>
<p style="margin: 0px"><span style="color: blue">#r</span> <span style="color: maroon">&quot;FakeLib.dll&quot;</span></p>
<p style="margin: 0px"><span style="color: blue">open</span> Fake</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: green">// Properties</span></p>
<p style="margin: 0px"><span style="color: blue">let</span> buildDir = <span style="color: maroon">@&quot;.\build\&quot;</span></p>
<p style="margin: 0px"><span style="color: blue">let</span> testDir&#160; = <span style="color: maroon">@&quot;.\test\&quot;</span></p>
<p style="margin: 0px"><span style="color: blue">let</span> appReferences&#160; = !+ <span style="color: maroon">@&quot;src\app\**\*.csproj&quot;</span> |&gt; Scan</p>
<p style="margin: 0px"><span style="color: blue">let</span> testReferences = !+ <span style="color: maroon">@&quot;src\test\**\*.csproj&quot;</span> |&gt; Scan</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: green">// Targets</span></p>
<p style="margin: 0px">Target? Clean &lt;-</p>
<p style="margin: 0px">&#160; <span style="color: blue">fun</span> _ –<span style="color: blue">&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; CleanDir buildDir</p>
<p style="margin: 0px">&#160;&#160;&#160; CleanDir testDir</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">Target? BuildApp &lt;-</p>
<p style="margin: 0px">&#160; <span style="color: blue">fun</span> _ <span style="color: blue">-&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">let</span> target = <span style="color: maroon">&quot;Build&quot;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: green">// compile all projects below src/app/ in Release mode</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">let</span> apps = MSBuildRelease buildDir target appReferences</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: green">// log the output files</span></p>
<p style="margin: 0px">&#160;&#160;&#160; Log <span style="color: maroon">&quot;AppBuild-Output: &quot;</span> apps</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">Target? BuildTest &lt;-</p>
<p style="margin: 0px">&#160; <span style="color: blue">fun</span> _ <span style="color: blue">-&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">let</span> testApps = MSBuildDebug testDir <span style="color: maroon">&quot;Build&quot;</span> testReferences</p>
<p style="margin: 0px">&#160;&#160;&#160; Log <span style="color: maroon">&quot;TestBuild-Output: &quot;</span> testApps&#160;&#160; </p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">Target? Default &lt;-</p>
<p style="margin: 0px">&#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"><span style="color: green">// Dependencies</span></p>
<p style="margin: 0px">For? BuildApp &lt;- Dependency? Clean</p>
<p style="margin: 0px">For? BuildTest &lt;- Dependency? Clean</p>
<p style="margin: 0px">For? Default &lt;-</p>
<p style="margin: 0px">&#160;&#160;&#160; Dependency? BuildApp</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160; |&gt; And? BuildTest</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: green">// start build</span></p>
<p style="margin: 0px">Run? Default</p>
</p></div>
<p>This time we define a new target “BuildTest”, which compiles all C# projects below src/test/ in Debug mode and we mark the target as a dependency of Default.</p>
<p>As you can see the Clean target is now a dependency of BuildApp and BuildTest, since we also have to clean the test dir. Although the Clean target is referenced twice the “FAKE – F# Make” runtime ensures that it will only be executed once.</p>
<p>The execution order is now Clean ==&gt; BuildApp ==&gt; BuildTest ==&gt; Default.</p>
<h5>Testing the test assemblies with NUnit</h5>
<p>Now all our projects will be compiled and we can use the NUnit task in order to test our test assemblies:</p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<p style="margin: 0px"><span style="color: green">// include Fake libs</span></p>
<p style="margin: 0px"><span style="color: blue">#I</span> <span style="color: maroon">@&quot;tools\FAKE&quot;</span></p>
<p style="margin: 0px"><span style="color: blue">#r</span> <span style="color: maroon">&quot;FakeLib.dll&quot;</span></p>
<p style="margin: 0px"><span style="color: blue">open</span> Fake</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: green">// Properties</span></p>
<p style="margin: 0px"><span style="color: blue">let</span> buildDir = <span style="color: maroon">@&quot;.\build\&quot;</span></p>
<p style="margin: 0px"><span style="color: blue">let</span> testDir&#160; = <span style="color: maroon">@&quot;.\test\&quot;</span></p>
<p style="margin: 0px"><span style="color: blue">let</span> appReferences&#160; = !+ <span style="color: maroon">@&quot;src\app\**\*.csproj&quot;</span> |&gt; Scan</p>
<p style="margin: 0px"><span style="color: blue">let</span> testReferences = !+ <span style="color: maroon">@&quot;src\test\**\*.csproj&quot;</span> |&gt; Scan</p>
<p style="margin: 0px"><span style="color: blue">let</span> testAssemblies = !+ (testDir + <span style="color: maroon">@&quot;\NUnit.Test.*.dll&quot;</span>) |&gt; Scan</p>
<p style="margin: 0px"><span style="color: blue">let</span> nunitPath = <span style="color: maroon">@&quot;.\Tools\NUnit\bin&quot;</span></p>
<p style="margin: 0px"><span style="color: blue">let</span> nunitOutput = testDir + <span style="color: maroon">@&quot;TestResults.xml&quot;</span></p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: green">// Targets</span></p>
<p style="margin: 0px">Target? Clean &lt;-</p>
<p style="margin: 0px">&#160; <span style="color: blue">fun</span> _ <span style="color: blue">-&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; CleanDir buildDir</p>
<p style="margin: 0px">&#160;&#160;&#160; CleanDir testDir</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">Target? BuildApp &lt;-</p>
<p style="margin: 0px">&#160; <span style="color: blue">fun</span> _ <span style="color: blue">-&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">let</span> target = <span style="color: maroon">&quot;Build&quot;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: green">// compile all projects below src/app/ in Release mode</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">let</span> apps = MSBuildRelease buildDir target appReferences</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: green">// log the output files</span></p>
<p style="margin: 0px">&#160;&#160;&#160; Log <span style="color: maroon">&quot;AppBuild-Output: &quot;</span> apps</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">Target? BuildTest &lt;-</p>
<p style="margin: 0px">&#160; <span style="color: blue">fun</span> _ <span style="color: blue">-&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">let</span> testApps = MSBuildDebug testDir <span style="color: maroon">&quot;Build&quot;</span> testReferences</p>
<p style="margin: 0px">&#160;&#160;&#160; Log <span style="color: maroon">&quot;TestBuild-Output: &quot;</span> testApps&#160;&#160; </p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">Target? Test &lt;-</p>
<p style="margin: 0px">&#160; <span style="color: blue">fun</span> _ <span style="color: blue">-&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; NUnit (<span style="color: blue">fun</span> p <span style="color: blue">-&gt;</span></p>
<p style="margin: 0px">&#160;&#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; ToolPath = nunitPath;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; DisableShadowCopy = <span style="color: blue">true</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; OutputFile = nunitOutput})</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160; testAssemblies</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">Target? Default &lt;-</p>
<p style="margin: 0px">&#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"><span style="color: green">// Dependencies</span></p>
<p style="margin: 0px">For? BuildApp &lt;- Dependency? Clean</p>
<p style="margin: 0px">For? BuildTest &lt;- Dependency? Clean</p>
<p style="margin: 0px">For? Test &lt;-</p>
<p style="margin: 0px">&#160;&#160;&#160; Dependency? BuildApp</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160; |&gt; And? BuildTest</p>
<p style="margin: 0px">For? Default &lt;- Dependency? Test&#160;&#160;&#160; </p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: green">// start build</span></p>
<p style="margin: 0px">Run? Default</p>
</p></div>
<p>Our new target “Test” scans the test directory for test assemblies and runs them with NUnit. The mysterious part <strong>(fun p –&gt; …) </strong>simply overrides the default parameters of the NUnit task and allows to specify concrete parameters.</p>
<p>The execution order is now Clean ==&gt; BuildApp ==&gt; BuildTest ==&gt; Test ==&gt; Default.</p>
<p><a href="http://www.navision-blog.de/images/GettingstartedwithFAKEFMakeGetridofthen_10682/image_4.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Test output" border="0" alt="Test output" src="http://www.navision-blog.de/images/GettingstartedwithFAKEFMakeGetridofthen_10682/image_thumb_4.png" width="504" height="192" /></a></p>
<h5>Deploying a zip file</h5>
<p>Now we want to deploy a *.zip file containing our application:</p>
<div style="font-family: courier new; background: white; color: black; font-size: 10pt">
<p style="margin: 0px"><span style="color: green">// include Fake libs</span></p>
<p style="margin: 0px"><span style="color: blue">#I</span> <span style="color: maroon">@&quot;tools\FAKE&quot;</span></p>
<p style="margin: 0px"><span style="color: blue">#r</span> <span style="color: maroon">&quot;FakeLib.dll&quot;</span></p>
<p style="margin: 0px"><span style="color: blue">open</span> Fake</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: green">// Properties</span></p>
<p style="margin: 0px"><span style="color: blue">let</span> buildDir = <span style="color: maroon">@&quot;.\build\&quot;</span></p>
<p style="margin: 0px"><span style="color: blue">let</span> testDir&#160; = <span style="color: maroon">@&quot;.\test\&quot;</span></p>
<p style="margin: 0px"><span style="color: blue">let</span> deployDir&#160; = <span style="color: maroon">@&quot;.\deploy\&quot;</span></p>
<p style="margin: 0px"><span style="color: blue">let</span> appReferences&#160; = !+ <span style="color: maroon">@&quot;src\app\**\*.csproj&quot;</span> |&gt; Scan</p>
<p style="margin: 0px"><span style="color: blue">let</span> testReferences = !+ <span style="color: maroon">@&quot;src\test\**\*.csproj&quot;</span> |&gt; Scan</p>
<p style="margin: 0px"><span style="color: blue">let</span> testAssemblies = !+ (testDir + <span style="color: maroon">@&quot;\NUnit.Test.*.dll&quot;</span>) |&gt; Scan</p>
<p style="margin: 0px"><span style="color: blue">let</span> nunitPath = <span style="color: maroon">@&quot;.\Tools\NUnit\bin&quot;</span></p>
<p style="margin: 0px"><span style="color: blue">let</span> nunitOutput = testDir + <span style="color: maroon">@&quot;TestResults.xml&quot;</span></p>
<p style="margin: 0px"><span style="color: blue">let</span> filesToZip = !+ (buildDir + <span style="color: maroon">&quot;\**\*.*&quot;</span>) &#8212; <span style="color: maroon">&quot;*.zip&quot;</span> |&gt; Scan</p>
<p style="margin: 0px"><span style="color: blue">let</span> zipFileName = deployDir + <span style="color: maroon">&quot;Calculator.zip&quot;</span></p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: green">// Targets</span></p>
<p style="margin: 0px">Target? Clean &lt;-</p>
<p style="margin: 0px">&#160; <span style="color: blue">fun</span> _ <span style="color: blue">-&gt;</span> CleanDirs [buildDir; testDir; deployDir]</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">Target? BuildApp &lt;-</p>
<p style="margin: 0px">&#160; <span style="color: blue">fun</span> _ <span style="color: blue">-&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">let</span> target = <span style="color: maroon">&quot;Build&quot;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: green">// compile all projects below src/app/ in Release mode</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">let</span> apps = MSBuildRelease buildDir target appReferences</p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: green">// log the output files</span></p>
<p style="margin: 0px">&#160;&#160;&#160; Log <span style="color: maroon">&quot;AppBuild-Output: &quot;</span> apps</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">Target? BuildTest &lt;-</p>
<p style="margin: 0px">&#160; <span style="color: blue">fun</span> _ <span style="color: blue">-&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; <span style="color: blue">let</span> testApps = MSBuildDebug testDir <span style="color: maroon">&quot;Build&quot;</span> testReferences</p>
<p style="margin: 0px">&#160;&#160;&#160; Log <span style="color: maroon">&quot;TestBuild-Output: &quot;</span> testApps&#160;&#160; </p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">Target? Test &lt;-</p>
<p style="margin: 0px">&#160; <span style="color: blue">fun</span> _ <span style="color: blue">-&gt;</span></p>
<p style="margin: 0px">&#160;&#160;&#160; NUnit (<span style="color: blue">fun</span> p <span style="color: blue">-&gt;</span></p>
<p style="margin: 0px">&#160;&#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; ToolPath = nunitPath;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; DisableShadowCopy = <span style="color: blue">true</span>;</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; OutputFile = nunitOutput})</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160; testAssemblies</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">Target? Deploy &lt;-</p>
<p style="margin: 0px">&#160; <span style="color: blue">fun</span> _ <span style="color: blue">-&gt;</span> Zip buildDir zipFileName filesToZip</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px">Target? Default &lt;- DoNothing</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: green">// Dependencies</span></p>
<p style="margin: 0px">For? BuildApp &lt;- Dependency? Clean</p>
<p style="margin: 0px">For? BuildTest &lt;- Dependency? Clean</p>
<p style="margin: 0px">For? Test &lt;-</p>
<p style="margin: 0px">&#160;&#160;&#160; Dependency? BuildApp</p>
<p style="margin: 0px">&#160;&#160;&#160;&#160;&#160; |&gt; And? BuildTest</p>
<p style="margin: 0px">For? Deploy &lt;- Dependency? Test</p>
<p style="margin: 0px">For? Default &lt;- Dependency? Deploy</p>
<p style="margin: 0px">&#160;</p>
<p style="margin: 0px"><span style="color: green">// start build</span></p>
<p style="margin: 0px">Run? Default</p>
</p></div>
<p>The new target “Deploy” scans the build directory for all files but zip-files. The result will be zipped to <em>\deploy\Calculator.zip</em> via the Zip task.</p>
<p>The execution order is now Clean ==&gt; BuildApp ==&gt; BuildTest ==&gt; Test ==&gt; Deploy ==&gt; Default whereas Default now is only used as a entry point.</p>
<h5></h5>
<h5>What’s next?</h5>
<p>Now your build file should look like <em>completeBuild.fsx</em> and you are ready to write your own “FAKE – F# Make” build scripts. If you have any questions or suggestions feel free to comment on this post.</p>
<p>In the <a href="http://www.navision-blog.de/2009/04/02/adding-fxcop-to-a-fake-build-script/">next article</a> I will show how we can add FxCop to our build in order to check specific naming rules.</p>
<p>&copy;2010 <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/04/01/getting-started-with-fake-a-f-sharp-make-tool/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
