Skip to content

Instantly share code, notes, and snippets.

@RussellPolitzky
Last active December 19, 2016 20:00
Show Gist options
  • Save RussellPolitzky/e2064ffe00fd01531dc3 to your computer and use it in GitHub Desktop.
Save RussellPolitzky/e2064ffe00fd01531dc3 to your computer and use it in GitHub Desktop.
Sample FAKE build script.
#r @"..\packages\FAKE.2.15.4\tools\FakeLib.dll"
open System
open Fake
open Fake.FileSystemHelper
open System.Diagnostics
let baseDir = __SOURCE_DIRECTORY__
let targetPlatform = "net-4.5"
let nunitPath = @"C:\Program Files (x86)\NUnit 2.6.3\bin"
let ilMergePath = combinePaths baseDir @"../packages/ilmerge.2.13.0307/ILMerge.exe"
let primaryAssemblyName = "FinancialModellingFundamentals.dll"
let outputDir = combinePaths baseDir "./Release"
let mergedAssemblyName = "FinModelCore.dll"
let mergedOutputDir = combinePaths baseDir "./ReleaseMerged"
let testOutputDir = combinePaths baseDir "./Tests"
let libraryProjectFile = !! "../FinancialModellingFundamentals/*.fsproj" |> SetBaseDir baseDir |> Seq.toList
let testsProjectFile = !! "../FinancialModellingFundamentals.Tests/*.fsproj" |> SetBaseDir baseDir |> Seq.toList
let testAssemblies = !! (testOutputDir + "/*.Tests.dll") |> SetBaseDir baseDir |> Seq.toList
// Clean all output folders.
Target "Clean" (fun _ -> CleanDirs [ outputDir; testOutputDir; mergedOutputDir ])
// Build the test project and its deps.
Target "BuildTests" (fun _ -> MSBuildDebug testOutputDir "Build" testsProjectFile |> Log "AppBuild-Output: ")
// Run all tests against the built test assemblies.
Target "NUnitTest" (fun _ ->
testAssemblies
|> NUnit (fun p ->
{p with
ToolPath = nunitPath
Framework = targetPlatform
DisableShadowCopy = true;
OutputFile = testOutputDir + "TestResults.xml"})
)
// Build the library in release mode.
Target "BuildLibrary" (fun _ -> MSBuildRelease outputDir "Build" libraryProjectFile |> Log "AppBuild-Output: ")
// Merge all into one assembly.
Target "IlMerge" (fun _ ->
ILMerge (fun p -> {p with
ToolPath = ilMergePath
TargetKind = Library })
(combinePaths mergedOutputDir mergedAssemblyName)
(combinePaths outputDir primaryAssemblyName)
)
"Clean" ==>
"BuildTests" ==>
"NUnitTest" ==>
"BuildLibrary" ==>
"IlMerge"
Run "IlMerge"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment