22// FAKE build script
33// --------------------------------------------------------------------------------------
44
5- #r " ./packages/build/FAKE/tools/FakeLib.dll"
5+ #load " .fake/build.fsx/intellisense.fsx"
6+
7+ #if ! FAKE
8+ #r " netstandard"
9+ #endif
610
7- open Fake
811open System
912
13+ open Fake.SystemHelper
14+ open Fake.Core
15+ open Fake.DotNet
16+ open Fake.Tools
17+ open Fake.IO
18+ open Fake.IO .FileSystemOperators
19+ open Fake.IO .Globbing .Operators
20+ open Fake.Core .TargetOperators
21+ open Fake.Api
22+
1023// --------------------------------------------------------------------------------------
1124// Build variables
1225// --------------------------------------------------------------------------------------
1326
1427let buildDir = " ./build/"
15- let appReferences = !! " /**/*.fsproj"
16- let dotnetcliVersion = " 2.1.4"
17- let mutable dotnetExePath = " dotnet"
18-
19- // --------------------------------------------------------------------------------------
20- // Helpers
21- // --------------------------------------------------------------------------------------
22-
23- let run ' timeout cmd args dir =
24- if execProcess ( fun info ->
25- info.FileName <- cmd
26- if not ( String.IsNullOrWhiteSpace dir) then
27- info.WorkingDirectory <- dir
28- info.Arguments <- args
29- ) timeout |> not then
30- failwithf " Error while running '%s ' with args: %s " cmd args
31-
32- let run = run' System.TimeSpan.MaxValue
33-
34- let runDotnet workingDir args =
35- let result =
36- ExecProcess ( fun info ->
37- info.FileName <- dotnetExePath
38- info.WorkingDirectory <- workingDir
39- info.Arguments <- args) TimeSpan.MaxValue
40- if result <> 0 then failwithf " dotnet %s failed" args
28+ let dotnetSdkVersion = " 3.1.101"
4129
4230// --------------------------------------------------------------------------------------
4331// Targets
4432// --------------------------------------------------------------------------------------
4533
46- Target " Clean" ( fun _ ->
47- CleanDirs [ buildDir]
34+ Target.create " Clean" ( fun _ ->
35+ [ buildDir]
36+ |> Shell.cleanDirs
4837)
4938
50- Target " InstallDotNetCLI" ( fun _ ->
51- dotnetExePath <- DotNetCli.InstallDotNetSDK dotnetcliVersion
39+ // Lazily install DotNet SDK in the correct version if not available
40+ let installedSdk =
41+ lazy DotNet.install ( fun cfg ->
42+ { cfg with
43+ Version = DotNet.CliVersion.Version dotnetSdkVersion
44+ })
45+
46+ // Set general properties without arguments
47+ let inline setDotNetOptions arg = DotNet.Options.lift installedSdk.Value arg
48+
49+ Target.create " InstallDotNetCLI" ( fun _ ->
50+ installedSdk.Force()
51+ |> ignore
5252)
5353
54- Target " Restore" ( fun _ ->
55- appReferences
56- |> Seq.iter ( fun p ->
57- let dir = System.IO.Path.GetDirectoryName p
58- runDotnet dir " restore"
59- )
54+ Target.create " Restore" ( fun _ ->
55+ DotNet.restore setDotNetOptions " DomainModelingMadeFunctional.sln"
6056)
6157
62- Target " Build" ( fun _ ->
63- appReferences
64- |> Seq.iter ( fun p ->
65- let dir = System.IO.Path.GetDirectoryName p
66- runDotnet dir " build"
67- )
58+ Target.create " Build" ( fun _ ->
59+ DotNet.exec setDotNetOptions " build" " DomainModelingMadeFunctional.sln"
60+ |> ignore
6861)
6962
7063// --------------------------------------------------------------------------------------
7164// Build order
7265// --------------------------------------------------------------------------------------
7366
7467" Clean"
75- ==> " InstallDotNetCLI"
76- ==> " Restore"
77- ==> " Build"
68+ ==> " InstallDotNetCLI"
69+ ==> " Restore"
70+ ==> " Build"
7871
79- RunTargetOrDefault " Build"
72+ Target.runOrDefaultWithArguments " Build"
0 commit comments