-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.fsx
112 lines (92 loc) · 3.2 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
101
102
103
104
105
106
107
108
109
110
111
112
#r "paket:
nuget Xake ~> 1.1 prerelease //"
#if !FAKE
#load ".fake/build.fsx/intellisense.fsx"
#endif
open Xake
open Xake.Tasks
let getVersion () = recipe {
let! verVar = getVar("VER")
let! verEnv = getEnv("VER")
return verVar |> Option.defaultValue (verEnv |> Option.defaultValue "0.0.1")
}
let makePackageName = sprintf "Xake.Dotnet.%s.nupkg"
let dotnet arglist =
shell {
cmd "dotnet"
args arglist
failonerror
} |> Recipe.Ignore
do xakeScript {
filelog "build.log" Verbosity.Diag
// consolelog Verbosity.Normal
rules [
"main" <<< ["build"; "test"]
"clean" => rm {dir "out"}
"build" <==
[ for t in ["netstandard2.0"; "net46"] do
for e in ["dll"; "xml"]
-> sprintf "out/%s/Xake.Dotnet.%s" t e
]
"test" => recipe {
do! alwaysRerun()
let! where =
getVar("FILTER")
|> Recipe.map (function |Some clause -> ["--filter"; sprintf "Name~\"%s\"" clause] | None -> [])
// in case of travis only run tests for standard runtime, eventually will add more
let! limitFwk = getEnv("TRAVIS") |> Recipe.map (function | Some _ -> ["-f:netcoreapp2.0"] | _ -> [])
do! dotnet <| ["test"; "tests"; "-c"; "Release"] @ where @ limitFwk
}
[ "out/(fwk:*)/Xake.Dotnet.dll"
"out/(fwk:*)/Xake.Dotnet.xml"] *..> recipe {
do! fileset {
basedir "src"
includes "Xake.Dotnet.fsproj"
includes "**/*.fs"
}
|> getFiles
|> Recipe.map needFiles
|> Recipe.Ignore
let! framework = getRuleMatch "fwk"
let! version = getVersion()
do! dotnet
[
"build"
"src"
"/p:Version=" + version
"--configuration"; "Release"
"--framework"; framework
"--output"; "../out/" + framework
"/p:DocumentationFile=Xake.Dotnet.xml"
]
}
(* Nuget publishing rules *)
"pack" => recipe {
let! version = getVersion()
do! need ["out" </> makePackageName version]
}
"out/Xake.Dotnet.(ver:*).nupkg" ..> recipe {
let! ver = getRuleMatch("ver")
do! dotnet
[
"pack"; "src"
"-c"; "Release"
"/p:Version=" + ver
"--output"; "../out/"
"/p:DocumentationFile=Xake.Dotnet.xml"
]
}
// push need pack to be explicitly called in advance
"push" => recipe {
let! version = getVersion()
let! nuget_key = getEnv("NUGET_KEY")
do! dotnet
[
"nuget"; "push"
"out" </> makePackageName version
"--source"; "https://www.nuget.org/api/v2/package"
"--api-key"; nuget_key |> Option.defaultValue ""
]
}
]
}