"FAKE - F# Make" is completely written in F# and all build scripts will also be written in F#, but this doesn't imply that you have to learn programming in F#. In fact the "FAKE - F# Make" syntax is hopefully very easy to learn.

There are various ways to install FAKE 5

Install the 'fake' or 'fake-netcore' package for you system (currenty chocolatey)
Example choco install fake -pre

Use it as dotnet tool: Add <DotNetCliToolReference Include="dotnet-fake" Version="5.0.0-*" /> to your dependencies and run dotnet fake ... instead of fake ..., see this example

Install fake as a global dotnet tool: run dotnet tool install fake-cli -g --version=5.0.0-* to install fake globally or dotnet tool install fake-cli --tool-path your_tool_path --version=5.0.0-* to install fake into your_tool_path. Use --version to specify the version of fake. See the global_tool branch of fake-bootstrap for ideas to bootstrap in your CI process.

INFO

As FAKE 5 is still in pre-release, you have to specify the --version parameter.

INFO

run the script to restore your dependencies and setup the intellisense support: fake run myscript.fsx.
This might take some seconds depending on your internet connection

INFO

The warning FS0988: Main module of program is empty: nothing will happen when it is run indicates that you have not written any code into the script yet.

now open the script in VS Code with ionide-fsharp extension or Visual Studio.

INFO

If you change your dependencies you need to delete myscript.fsx.lock and run the script again for intellisense to update.
Intellisense is shown for the full framework while the script is run as netcoreapp20 therefore intellisense might show APIs which are not actually usable.

As you can see the code is really simple. The few first lines (nuget Fake.Core.Target and open Fake.Core) load the fake modules we need and is vital for all build scripts to support creating and running targets. The #load line is optional but a good way to make the IDE aware of all the modules (for intellisense and IDE support)

After this header the Default target is defined. A target definition contains 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").

The last line runs the "Default" target - which means it executes the defined action of the target.

Try running your new target via fake run build.fsx or the shortcut for a file called build.fsx: fake build

Now we remove the build.fsx.lock file and run fake build in order to restore the newly added Fake.IO.FileSystem module.

As we can now work with intellisense we can easily discover the various modules and functions in Fake.IO, for example the Shell module provides various functions you expect from regular shell scripting, but we use Shell.CleanDir which will ensure the given directory is empty by deleting everything within or creating the directory if required:

We defined a new build target named "BuildApp" which compiles all csproj-files with the MSBuild task and the build output will be copied to buildDir.

In order to find the right project files FAKE scans the folder src/app/ and all subfolders with the given pattern (the !! operator was imported from Fake.IO.FileSystem via open Fake.IO.Globbing.Operators). Therefore a similar FileSet definition like in NAnt or MSBuild (see project page for details) is used.

In addition the target dependencies are extended again. Now Default is dependent on BuildApp and BuildApp needs Clean as a prerequisite.

Our new Test target scans the test directory for test assemblies and runs them with the NUnit runner. FAKE automatically tries to locate the runner in one of your subfolders. See the NUnit task documentation if you need to specify the tool path explicitly.

The mysterious part (fun p -> ...) simply overrides the default parameters of the NUnit task and allows to specify concrete parameters.