-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.fsx
100 lines (81 loc) · 2.08 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#r "paket:
nuget Fake.DotNet.Cli
nuget Fake.IO.FileSystem
nuget Fake.Core.Target //"
#load ".fake/build.fsx/intellisense.fsx"
open Fake.Core
open Fake.DotNet
open Fake.IO
open Fake.IO.FileSystemOperators
open Fake.IO.Globbing.Operators
open Fake.Core.TargetOperators
[<AutoOpen>]
module Utils =
let dotnet cmd arg =
let res = DotNet.exec id cmd arg
let msg = $"dotnet %s{cmd} %s{arg}"
if res.OK then
Trace.tracefn "Success '%s'" msg
else
failwithf "Failed '%s'" msg
let (|LowerCase|_|) (x: string) (s: string) =
if x.ToLower() = s.ToLower() then Some LowerCase else None
let getConfiguration = function
| Some (LowerCase("debug")) -> DotNet.BuildConfiguration.Debug
| Some (LowerCase("release")) -> DotNet.BuildConfiguration.Release
| Some (c) -> failwithf "Invalid configuration '%s'" c
| _ -> DotNet.BuildConfiguration.Debug
Target.initEnvironment ()
let args = Target.getArguments()
Target.create "Format" (fun _ ->
!! "src/**/*.csproj"
++ "tests/**/*.csproj"
++ "example/**/*.csproj"
|> Seq.iter (fun proj ->
dotnet "format" $"{proj} -v diag"
)
)
Target.create "Format.Check" (fun _ ->
!! "src/**/*.csproj"
++ "tests/**/*.csproj"
++ "example/**/*.csproj"
|> Seq.iter (fun proj ->
dotnet "format" $"{proj} --verify-no-changes -v diag"
)
)
Target.create "Clean" (fun _ ->
!! "src/**/bin"
++ "src/**/obj"
++ "tests/**/bin"
++ "tests/**/obj"
++ "example/**/bin"
++ "example/**/obj"
|> Shell.cleanDirs
)
Target.create "Build" (fun _ ->
let configuration =
args
|> Option.bind Array.tryHead
|> getConfiguration
!! "src/**/*.*proj"
++ "tests/**/*.*proj"
++ "example/**/*.*proj"
|> Seq.iter (DotNet.build (fun p ->
{ p with
Configuration = configuration
}))
)
Target.create "Test" (fun _ ->
!! "tests/**/*.*proj"
|> Seq.iter(fun proj ->
DotNet.test (fun p ->
{ p with
Logger = Some "console;verbosity=normal"
}
) proj
)
)
Target.create "None" ignore
Target.create "Default" ignore
"Build" ==> "Default"
Target.runOrDefaultWithArguments "Default"