-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.fsx
84 lines (67 loc) · 2.21 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
76
77
78
79
80
81
82
83
84
#if !FAKE
#r "netstandard"
#endif
#r "paket:
nuget Fake.DotNet.Cli
nuget Fake.IO.FileSystem
nuget Fake.Core.Target //"
#load ".fake/build.fsx/intellisense.fsx"
open Fake.Core
open Fake.DotNet
open Fake.IO
open Fake.IO.FileSystemOperators
open Fake.IO.Globbing.Operators
open Fake.Core.TargetOperators
Target.initEnvironment ()
let projectPath = "./src/Feliz.Isomorphic"
let generatorPath = "./src/Generator"
let platformTool tool winTool =
let tool = if Environment.isUnix then tool else winTool
tool
|> ProcessUtils.tryFindFileOnPath
|> function Some t -> t | _ -> failwithf "%s not found" tool
let runTool cmd args workingDir =
let arguments = args |> String.split ' ' |> Arguments.OfArgs
Command.RawCommand (cmd, arguments)
|> CreateProcess.fromCommand
|> CreateProcess.withWorkingDirectory workingDir
|> CreateProcess.ensureExitCode
|> Proc.run
|> ignore
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 delete file =
if System.IO.File.Exists(file)
then System.IO.File.Delete file
else ()
Target.create "Clean" (fun _ ->
!! "src/**/bin"
++ "src/**/obj"
|> Shell.cleanDirs
)
Target.create "Generate" (fun _ ->
runDotNet "run" generatorPath
)
Target.create "Build" (fun _ ->
runDotNet "build" projectPath
)
let publish projectPath = fun _ ->
runDotNet "restore --no-cache" projectPath
runDotNet "pack -c Release" projectPath
let nugetKey =
match Environment.environVarOrNone "FELIZ_ISOMORPHIC_NUGET_KEY" with
| Some nugetKey -> nugetKey
| None -> failwith "The Nuget API key must be set in a FELIZ_ISOMORPHIC_NUGET_KEY environmental variable"
let nupkg =
Directory.findFirstMatchingFile "*.nupkg" (projectPath </> "bin" </> "Release")
let pushCmd = sprintf "nuget push %s -s https://www.nuget.org/api/v2/package/ -k %s" nupkg nugetKey
runDotNet pushCmd projectPath
Target.create "Publish" (publish projectPath)
Target.create "All" ignore
"Clean"
==> "Generate"
==> "Build"
==> "Publish"
Target.runOrDefault "Build"