Created
May 26, 2018 09:55
-
-
Save JaykeOps/0a6dd53ccc12b81f71a3609b725015ac to your computer and use it in GitHub Desktop.
FS Build.fsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -------------------------------------------------------------------------------------- | |
// FAKE build script | |
// -------------------------------------------------------------------------------------- | |
#r "./packages/build/FAKE/tools/FakeLib.dll" | |
open Fake | |
open System | |
// -------------------------------------------------------------------------------------- | |
// Build variables | |
// -------------------------------------------------------------------------------------- | |
let buildDir = "./build/" | |
let appReferences = !! "/**/*.fsproj" | |
let dotnetcliVersion = "2.0.2" | |
let mutable dotnetExePath = "dotnet" | |
// -------------------------------------------------------------------------------------- | |
// Helpers | |
// -------------------------------------------------------------------------------------- | |
let run' timeout cmd args dir = | |
if execProcess (fun info -> | |
info.FileName <- cmd | |
if not (String.IsNullOrWhiteSpace dir) then | |
info.WorkingDirectory <- dir | |
info.Arguments <- args | |
) timeout |> not then | |
failwithf "Error while running '%s' with args: %s" cmd args | |
let run = run' System.TimeSpan.MaxValue | |
let runDotnet workingDir args = | |
let result = | |
ExecProcess (fun info -> | |
info.FileName <- dotnetExePath | |
info.WorkingDirectory <- workingDir | |
info.Arguments <- args) TimeSpan.MaxValue | |
if result <> 0 then failwithf "dotnet %s failed" args | |
// -------------------------------------------------------------------------------------- | |
// Targets | |
// -------------------------------------------------------------------------------------- | |
Target "Clean" (fun _ -> | |
CleanDirs [buildDir] | |
) | |
Target "InstallDotNetCLI" (fun _ -> | |
dotnetExePath <- DotNetCli.InstallDotNetSDK dotnetcliVersion | |
) | |
Target "Restore" (fun _ -> | |
appReferences | |
|> Seq.iter (fun p -> | |
let dir = System.IO.Path.GetDirectoryName p | |
runDotnet dir "restore" | |
) | |
) | |
Target "Build" (fun _ -> | |
appReferences | |
|> Seq.iter (fun p -> | |
let dir = System.IO.Path.GetDirectoryName p | |
runDotnet dir "build" | |
) | |
) | |
// -------------------------------------------------------------------------------------- | |
// Build order | |
// -------------------------------------------------------------------------------------- | |
"Clean" | |
==> "InstallDotNetCLI" | |
==> "Restore" | |
==> "Build" | |
RunTargetOrDefault "Build" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment