-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.fs
executable file
·88 lines (75 loc) · 2.34 KB
/
run.fs
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
open Fake.IO
open RunHelpers
open RunHelpers.Templates
open System.IO
[<RequireQualifiedAccess>]
module Config =
let srcPath = "./src"
let testPath = "./tests"
let examplesPath = "./examples"
let packPath = "./deploy"
let inline isFsproj (file: string) = file.EndsWith ".fsproj"
let inline isCsproj (file: string) = file.EndsWith ".csproj"
let inline isProj (file: string) = isFsproj file || isCsproj file
let inline getProjectsFromFolder folder =
folder
|> Seq.collect (fun folder -> Directory.EnumerateFiles(folder, "*", SearchOption.AllDirectories))
|> Seq.filter isProj
let inline getAllProjects () =
getProjectsFromFolder [ Config.srcPath; Config.testPath; Config.examplesPath ]
let inline getTestProjects () =
getProjectsFromFolder [ Config.testPath ]
let inline getSrcProjects () =
getProjectsFromFolder [ Config.srcPath ]
[<RequireQualifiedAccess>]
module Task =
let restore () =
job {
DotNet.toolRestore ()
for project in getAllProjects () do
DotNet.restore project
}
let build config =
job {
for project in getAllProjects () do
DotNet.build project config
}
let test () =
parallelJob {
for project in getTestProjects () do
DotNet.run project
}
let pack version =
job {
Shell.cleanDir Config.packPath
parallelJob {
for project in getSrcProjects () do
DotNet.pack Config.packPath project version
}
}
// We determine, what we want to execute
[<EntryPoint>]
let main args : int =
List.ofArray args
|> function
| [ "restore" ] -> Task.restore ()
| [ "build" ] ->
job {
Task.restore ()
Task.build Debug
}
| [ "test" ] ->
job {
Task.restore ()
Task.test ()
}
| [ "pack"; version ] ->
job {
Task.restore ()
Task.build Debug
Task.pack version
}
// Catch errors and help
| [ "pack" ] -> Job.error [ "Usage: dotnet run pack <version>" ]
| _ -> Job.error [ "Usage: dotnet run <command>"; "Look up available commands in run.fs" ]
|> Job.execute