-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build.fs
48 lines (42 loc) · 2.1 KB
/
Build.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
module Scripts.Build
open System
open System.IO
open CliWrap
open Scripts
open Serilog
open Utils
let dotnetPath =
null // Environment.GetEnvironmentVariable("FSHARP_SCRIPTS_DOTNET")
|> Option.ofObj
|> Option.defaultValue "dotnet"
let rec restoreProject (projectPath : string) (extraArgs : string) =
if File.Exists(projectPath) = false then
failwith $"'{nameof restoreProject}' expects a project file path, but {projectPath} is not a file or it doesn't exist"
let projectFile = Path.GetFileName(projectPath)
Log.Information("Start restoreProject {projectPath}", projectPath)
Cli
.Wrap(dotnetPath)
.WithWorkingDirectory(Path.GetDirectoryName(projectPath))
.WithArguments($"restore {projectFile} {extraArgs}")
.ExecuteAssertSuccess()
Log.Information("End restoreProject {projectPath}", projectPath)
let rec buildProject (projectPath : string) (binlogOutputPath : string option) (extraArgs : string) =
if File.Exists(projectPath) = false then
failwith $"'{nameof buildProject}' expects a project file path, but {projectPath} is not a file or it doesn't exist"
let projectFile = Path.GetFileName(projectPath)
Log.Information("Start buildProject {projectPath}", projectPath)
let binlogArg = match binlogOutputPath with Some binlogOutputPath -> $"/bl:{binlogOutputPath}" | None -> ""
Cli
.Wrap(dotnetPath)
.WithWorkingDirectory(Path.GetDirectoryName(projectPath))
.WithArguments($"build {projectFile} {binlogArg} {extraArgs}")
.ExecuteAssertSuccess()
Log.Information("End buildProject {projectPath}", projectPath)
let rec buildSingleProjectMinimalNoIncremental (projectPath : string) (binlogOutputPath : string option) (extraArgs : string) =
let extraArgs = extraArgs + " --no-incremental --no-dependencies --no-restore"
buildProject projectPath binlogOutputPath extraArgs
let buildMSBuildPropsArg (msbuildProps: Map<string, string> option) =
msbuildProps
|> Option.defaultValue Map.empty
|> Seq.map (fun (KeyValue(k, v)) -> $"/p:{k}={v}")
|> fun items -> String.Join(" ", items)