-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.fsx
79 lines (63 loc) · 2.42 KB
/
build.fsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// --------------------------------------------------------------------------------------
// 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"