How Is This Look Like?
Lets look at a Demo solution:
\Demo
\Demo.App
\Demo.Lib
\Demo.Lib.Test
- Demo.sln
- build.fsx
The build.fsx defines build steps:
Tfs.PlugIn()
let out = ~~".out"
let productOut = out / "product"
let testsOut = out / "tests"
let tests = !!"*/*.Test.csproj"
let product =
!!"*/*.csproj"
- tests
"Clean" => (fun _ ->
let obj = !!!"*/obj"
let bin = !!!"*/bin"
Folders.Clean obj
Folders.Clean bin
Folders.Clean out
)
"Compile" => (fun _ ->
MsBuild.BuildRelease(product, productOut)
MsBuild.BuildRelease(tests, testsOut)
)
"Test.Unit" => (fun _ ->
VsTest.Run(
testsOut % "*.Test.dll")
)
"Test" <== ["Test.Unit"]
"Build" <== ["Compile"; "Test"]
You can run build either locally...
\Projects\Demo\dev> anf Clean Compile
...or on Team Build server
Benefits
- build.fsx is under version control and will be branched with a solution (this is especially important when build steps change from branch to branch);
- it's possible to test build locally before commit;
- for most developers it is easier to edit script (in usual editor with IntelliSense working!) instead of build process template;
- it's significantly easy to debug local script than build workflow on remote machine.
How to Get AnFake
AnFake is available on NuGet.
To install the tool, run the following command in the Package Manager Console:
PM> Install-Package AnFake