forked from Dzoukr/CosmoStore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.fsx
103 lines (81 loc) · 4.32 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#r "paket: groupref Build //"
#load ".fake/build.fsx/intellisense.fsx"
open System.IO
open Fake.IO
open Fake.Core
open Fake.DotNet
open Fake.IO.FileSystemOperators
open Fake.Core.TargetOperators
module Tools =
let private findTool tool winTool =
let tool = if Environment.isUnix then tool else winTool
match ProcessUtils.tryFindFileOnPath tool with
| Some t -> t
| _ ->
let errorMsg =
tool + " was not found in path. " +
"Please install it and make sure it's available from your path. "
failwith errorMsg
let private runTool (cmd:string) args workingDir =
let arguments = args |> String.split ' ' |> Arguments.OfArgs
Command.RawCommand (cmd, arguments)
|> CreateProcess.fromCommand
|> CreateProcess.withWorkingDirectory workingDir
|> CreateProcess.ensureExitCode
|> Proc.run
|> ignore
let dotnet cmd workingDir =
let result =
DotNet.exec (DotNet.Options.withWorkingDirectory workingDir) cmd ""
if result.ExitCode <> 0 then failwithf "'dotnet %s' failed in %s" cmd workingDir
// Targets
let clean proj = [ proj </> "bin"; proj </> "obj" ] |> Shell.cleanDirs
let createNuget proj =
clean proj
Tools.dotnet "restore --no-cache" proj
Tools.dotnet "pack -c Release" proj
let publishNuget proj =
createNuget proj
let nugetKey =
match Environment.environVarOrNone "NUGET_KEY" with
| Some nugetKey -> nugetKey
| None -> failwith "The Nuget API key must be set in a NUGET_KEY environmental variable"
let nupkg =
Directory.GetFiles(proj </> "bin" </> "Release")
|> Seq.head
|> Path.GetFullPath
Tools.dotnet (sprintf "nuget push %s -s nuget.org -k %s" nupkg nugetKey) proj
Target.create "PackCosmoStore" (fun _ -> "src" </> "CosmoStore" |> createNuget)
Target.create "PublishCosmoStore" (fun _ -> "src" </> "CosmoStore" |> publishNuget)
Target.create "TestCosmoStore" (fun _ -> Tools.dotnet "run" ("tests" </> "CosmoStore.Tests"))
Target.create "PackTableStorage" (fun _ -> "src" </> "CosmoStore.TableStorage" |> createNuget)
Target.create "PublishTableStorage" (fun _ -> "src" </> "CosmoStore.TableStorage" |> publishNuget)
Target.create "TestTableStorage" (fun _ -> Tools.dotnet "run" ("tests" </> "CosmoStore.TableStorage.Tests"))
"TestTableStorage" ==> "PackTableStorage"
"TestTableStorage" ==> "PublishTableStorage"
Target.create "PackCosmosDb" (fun _ -> "src" </> "CosmoStore.CosmosDb" |> createNuget)
Target.create "PublishCosmosDb" (fun _ -> "src" </> "CosmoStore.CosmosDb" |> publishNuget)
Target.create "TestCosmosDb" (fun _ -> Tools.dotnet "run" ("tests" </> "CosmoStore.CosmosDb.Tests"))
"TestCosmosDb" ==> "PackCosmosDb"
"TestCosmosDb" ==> "PublishCosmosDb"
Target.create "PackMarten" (fun _ -> "src" </> "CosmoStore.Marten" |> createNuget)
Target.create "PublishMarten" (fun _ -> "src" </> "CosmoStore.Marten" |> publishNuget)
Target.create "TestMarten" (fun _ -> Tools.dotnet "run" ("tests" </> "CosmoStore.Marten.Tests"))
"TestMarten" ==> "PackMarten"
"TestMarten" ==> "PublishMarten"
Target.create "PackInMemory" (fun _ -> "src" </> "CosmoStore.InMemory" |> createNuget)
Target.create "PublishInMemory" (fun _ -> "src" </> "CosmoStore.InMemory" |> publishNuget)
Target.create "TestInMemory" (fun _ -> Tools.dotnet "run" ("tests" </> "CosmoStore.InMemory.Tests"))
"TestInMemory" ==> "PackInMemory"
"TestInMemory" ==> "PublishInMemory"
Target.create "PackLiteDb" (fun _ -> "src" </> "CosmoStore.LiteDb" |> createNuget)
Target.create "PublishLiteDb" (fun _ -> "src" </> "CosmoStore.LiteDb" |> publishNuget)
Target.create "TestLiteDb" (fun _ -> Tools.dotnet "run" ("tests" </> "CosmoStore.LiteDb.Tests"))
"TestLiteDb" ==> "PackLiteDb"
"TestLiteDb" ==> "PublishLiteDb"
Target.create "PackServiceStack" (fun _ -> "src" </> "CosmoStore.ServiceStack" |> createNuget)
Target.create "PublishServiceStack" (fun _ -> "src" </> "CosmoStore.ServiceStack" |> publishNuget)
Target.create "TestServiceStack" (fun _ -> Tools.dotnet "run" ("tests" </> "CosmoStore.ServiceStack.Tests"))
"TestServiceStack" ==> "PackServiceStack"
"TestServiceStack" ==> "PublishServiceStack"
Target.runOrDefaultWithArguments "TestCosmoStore"