-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.fsx
75 lines (59 loc) · 1.92 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
#r "paket:
nuget FSharp.Core
nuget Fake.IO.FileSystem
nuget Fake.Core.Target
nuget Fake.DotNet.Cli //"
#load "./.fake/build.fsx/intellisense.fsx"
open Fake.Core
open Fake.DotNet
open Fake.IO
open Fake.IO.Globbing.Operators
let identityServerPath = Path.getFullName "./src/IdentityServer"
let apiServerPath = Path.getFullName "./src/Api"
let npm args workingDir =
let npmPath =
match ProcessUtils.tryFindFileOnPath "npm" with
| Some path -> path
| None ->
"npm was not found in path. Please install it and make sure it's available from your path. " +
"See https://safe-stack.github.io/docs/quickstart/#install-pre-requisites for more info"
|> failwith
let arguments = args |> String.split ' ' |> Arguments.OfArgs
Command.RawCommand (npmPath, arguments)
|> CreateProcess.fromCommand
|> CreateProcess.withWorkingDirectory workingDir
|> CreateProcess.ensureExitCode
|> Proc.run
|> ignore
let dotnet cmd workingDir =
let result = Fake.DotNet.DotNet.exec (Fake.DotNet.DotNet.Options.withWorkingDirectory workingDir) cmd ""
if result.ExitCode <> 0 then failwithf "'dotnet %s' failed in %s" cmd workingDir
// *** Define Targets ***
Target.create "Clean" (fun _ ->
Trace.log " --- Cleaning stuff --- "
Shell.rm_rf "node_modules"
GlobbingPattern.createFrom "public" ++ "**/*.js"
|> Seq.iter Shell.rm_rf
dotnet "clean" "."
)
Target.create "Build" (fun _ ->
Trace.log " --- Building the app --- "
dotnet "build" "."
npm "install" "."
)
Target.create "Run" (fun _ ->
Trace.log " --- Running the app --- "
[ async { dotnet "watch run" identityServerPath }
async { dotnet "watch run" apiServerPath }
async { npm "start" "." } ]
|> Async.Parallel
|> Async.RunSynchronously
|> ignore
)
open Fake.Core.TargetOperators
// *** Define Dependencies ***
"Clean"
==> "Build"
==> "Run"
// *** Start Build ***
Target.runOrDefault "Run"