-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.fsx
91 lines (68 loc) · 2.35 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
#!dotnet fsi
#r "netstandard"
#r "nuget: MSBuild.StructuredLogger"
#r "nuget: Fake.Core"
#r "nuget: Fake.Core.Target"
#r "nuget: Fake.Core.ReleaseNotes"
#r "nuget: Fake.IO.FileSystem"
#r "nuget: Fake.DotNet.Cli"
#r "nuget: Fake.DotNet.AssemblyInfoFile"
#r "nuget: Fake.Net.Http"
#r "nuget: FSharp.Json"
open System
open Fake.Core
open Fake.Core.TargetOperators
open Fake.DotNet
open Fake.IO
open Fake.IO.Globbing.Operators
// Boilerplate
System.Environment.GetCommandLineArgs()
|> Array.skip 2 // skip fsi.exe; build.fsx
|> Array.toList
|> Context.FakeExecutionContext.Create false __SOURCE_FILE__
|> Context.RuntimeContext.Fake
|> Context.setExecutionContext
Target.initEnvironment ()
let dotnet cmd arg =
let res = DotNet.exec id cmd arg
if not res.OK then
res.Messages |> String.concat "\n" |> Trace.trace
failwithf "failed 'dotnet %s %s'" cmd arg
let fsiExec path = dotnet "fsi" path
let release = ReleaseNotes.load "RELEASE_NOTES.md"
Target.create
"AssemblyInfo"
(fun _ ->
[ AssemblyInfo.Version release.AssemblyVersion
AssemblyInfo.FileVersion release.AssemblyVersion
AssemblyInfo.InformationalVersion release.NugetVersion ]
|> AssemblyInfoFile.createFSharp "./src/EffFs/AssemblyInfo.fs"
)
Target.create "Test" (fun _ -> !! "example/*.fsx" |> Seq.iter fsiExec)
Target.create "Tool" (fun _ -> dotnet "tool" "update fake-cli")
Target.create "Clean" (fun _ -> !! "src/**/bin" ++ "src/**/obj" |> Shell.cleanDirs)
Target.create "Build" (fun _ -> !! "src/**/*.*proj" |> Seq.iter (DotNet.build id))
Target.create
"Pack"
(fun _ ->
!! "src/**/*.*proj"
|> Seq.iter (
DotNet.pack (fun opt ->
{ opt with
Configuration = DotNet.BuildConfiguration.Release
OutputPath = Some "output/packages/"
MSBuildParams =
{ opt.MSBuildParams with
Properties = [ "PackageVersion", release.NugetVersion ] @ opt.MSBuildParams.Properties } }
)
)
)
let formatTargets =
!! "src/**/*.fs" ++ "build.fsx" ++ "example/*.fsx"
-- "src/*/obj/**/*.fs"
-- "src/*/bin/**/*.fs"
Target.create "Format" (fun _ -> formatTargets |> String.concat " " |> dotnet "fantomas")
Target.create "Format.Check" (fun _ -> formatTargets |> String.concat " " |> sprintf "--check %s" |> dotnet "fantomas")
Target.create "All" ignore
"Clean" ==> "Build" ==> "All"
Target.runOrDefault "All"