-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.fsx
75 lines (62 loc) · 2.27 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
#I "packages/FAKE/tools"
#r "FakeLib.dll"
#load "project.fsx"
open Fake
open Fake.AssemblyInfoFile
open Fake.ChangeWatcher
open Fake.FscHelper
open Fake.ProcessHelper
open Reload.Project
let ensureProjectLoaded() =
tracefn "Project definition loaded for directory: %s" project.BaseDir
let assemblyInfo = "AssemblyInfo.fs"
let createAssemblyInfo() =
CreateFSharpAssemblyInfo (System.IO.Path.Combine(project.BaseDir, assemblyInfo))
[Attribute.Title "Reload Demo"
Attribute.Description "Demonstration of compiling and watching F# tools with FAKE"
Attribute.Version project.Version
Attribute.FileVersion project.Version]
let compile() =
if project.GenerateAssemblyInfo then
createAssemblyInfo()
assemblyInfo::project.Files
else project.Files
|> Fsc (fun _ -> project.FscParams)
let run() =
Shell.Exec project.FscParams.Output |> ignore
let watch() =
use watcher =
{ BaseDirectory = project.BaseDir
Includes = project.Files
Excludes = [assemblyInfo] }
|> WatchChanges (fun changes ->
tracefn "%A" changes
// TODO: restore target running so as not to duplicate the dependency chain. https://github.com/fsharp/FAKE/issues/791
//Run "Run")
compile()
run())
// TODO: This appears to block.
System.Console.ReadLine() |> ignore
watcher.Dispose()
Target "EnsureProjectLoaded" ensureProjectLoaded
Target "AssemblyInfo" createAssemblyInfo
Target "Compile" compile
Target "Run" run
Target "Watch" watch
Target "Help" <| fun _ ->
// TODO: Include instructions for specifying the output name and files to compile.
printfn "build.(cmd|sh) [<target>] [options]"
printfn @"for FAKE help: packages\FAKE\tools\FAKE.exe --help"
printfn "targets:"
printfn " * AssemblyInfo - generates an `AssemblyInfo.fs`"
printfn " * Compile - builds a `.exe` from any `.fs` files in the root directory"
printfn " * Help - displays this message"
printfn " * Run - runs the generated `.exe`"
printfn " * Watch - recompiles and runs the `.exe` for any changes to any `.fs` files in the directory"
"EnsureProjectLoaded"
==> "AssemblyInfo"
"EnsureProjectLoaded"
==> "Compile"
==> "Run"
==> "Watch"
RunTargetOrDefault "Help"