-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
Helpers.fs
27 lines (23 loc) · 884 Bytes
/
Helpers.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
module Helpers
open Fake.Core
open Fake.DotNet
let initializeContext () =
let execContext = Context.FakeExecutionContext.Create false "build.fsx" [ ]
Context.setExecutionContext (Context.RuntimeContext.Fake execContext)
/// Executes a dotnet command in the given working directory
let runDotNet cmd workingDir =
let result =
DotNet.exec (DotNet.Options.withWorkingDirectory workingDir) cmd ""
if result.ExitCode <> 0 then failwithf "'dotnet %s' failed in %s" cmd workingDir
let runOrDefault defaultTarget args =
Trace.trace (sprintf "%A" args)
try
match args with
| [| target |] -> Target.runOrDefault target
| arr when args.Length > 1 ->
Target.run 0 (Array.head arr) ( Array.tail arr |> List.ofArray )
| _ -> Target.runOrDefault defaultTarget
0
with e ->
printfn "%A" e
1