-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.fsx
122 lines (99 loc) · 3.77 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#r "paket:
nuget Fake.DotNet.Cli
nuget Fake.IO.FileSystem
nuget Fake.DotNet.AssemblyInfoFile
nuget Fake.Core.ReleaseNotes
nuget Fake.DotNet.Paket
nuget Fake.Core.Target //"
// If you open this file the first time, run this script in `dotnet fsi` then errors will be gone in IDE
#load ".fake/build.fsx/intellisense.fsx"
open Fake.Core
open Fake.DotNet
open Fake.IO
open Fake.IO.FileSystemOperators
open Fake.Core.TargetOperators
open Fake.IO.Globbing.Operators
Target.initEnvironment ()
/// Directory that contains the produced .nupkg files
[<Literal>]
let PublishDirectory = "publish"
let releaseNotesFileName = "RELEASE_NOTES.md"
let releaseNotes = ReleaseNotes.load releaseNotesFileName
[<RequireQualifiedAccess>]
type Project =
| Core
| Tool
let projectDirs =
[ Project.Core, "FSharp.Data.NpgsqlGenerator.Core"
Project.Tool, "FSharp.Data.NpgsqlGenerator.Tool" ]
|> Map.ofList
let projectFiles =
[ Project.Core, "FSharp.Data.NpgsqlGenerator.Core.fsproj"
Project.Tool, "FSharp.Data.NpgsqlGenerator.Tool.fsproj" ]
|> Map.ofList
let projectPaths =
[ Project.Core, Path.combine projectDirs.[Project.Core] projectFiles.[Project.Core]
Project.Tool, Path.combine projectDirs.[Project.Tool] projectFiles.[Project.Tool] ]
|> Map.ofList
Target.create "AssemblyInfo" (fun _ ->
let version = releaseNotes.NugetVersion
AssemblyInfoFile.createFSharp
(projectDirs.[Project.Tool] </> "AssemblyInfo.fs")
[ AssemblyInfo.Title "FSharp.Data.NpgsqlGenerator.Tool"
AssemblyInfo.Description "FSharp.Data.NpgsqlGenerator source generator CLI app"
AssemblyInfo.Company "MechSym"
AssemblyInfo.Product "FSharp.Data.NpgsqlGenerator source generator CLI"
AssemblyInfo.Version version
AssemblyInfo.FileVersion version ]
AssemblyInfoFile.createFSharp
(projectDirs.[Project.Core] </> "AssemblyInfo.fs")
[ AssemblyInfo.Title "FSharp.Data.NpgsqlGenerator.Core"
AssemblyInfo.Description "FSharp.Data.NpgsqlGenerator source generator core"
AssemblyInfo.Company "MechSym"
AssemblyInfo.Product "FSharp.Data.NpgsqlGenerator source generator core"
AssemblyInfo.Version version
AssemblyInfo.FileVersion version ])
let addMsBuildOverrides (this: MSBuild.CliArguments) =
{ this with
Properties = ("Version", releaseNotes.NugetVersion) :: this.Properties }
Target.create "Clean" (fun _ ->
projectDirs
|> Map.values
|> Seq.collect (fun path -> [ Path.combine path "bin"; Path.combine path "obj" ])
|> Shell.cleanDirs
[ PublishDirectory ] |> Shell.cleanDirs)
Target.create "Build" (fun _ ->
projectPaths
|> Map.values
|> Seq.iter (
DotNet.build (fun parameters ->
{ parameters with
MSBuildParams = parameters.MSBuildParams |> addMsBuildOverrides })
))
Target.create "Pack" (fun _ ->
projectPaths
|> Map.values
|> Seq.iter (
DotNet.pack (fun parameters ->
{ parameters with
OutputPath = Some PublishDirectory
MSBuildParams = parameters.MSBuildParams |> addMsBuildOverrides })
))
Target.create "Push" (fun param ->
let source =
match param.Context.Arguments with
| [] -> None
| [ source ] -> Some source
| _ -> failwith "Accepting a single push argument"
!!(PublishDirectory </> "*.nupkg")
|> Seq.iter (fun nupkg ->
DotNet.nugetPush
(fun parameters ->
{ parameters with
PushParams =
{ parameters.PushParams with
Source = source } })
nupkg))
Target.create "All" ignore
"Clean" ==> "AssemblyInfo" ==> "Build" ==> "Pack" ==> "Push" ==> "All"
Target.runOrDefaultWithArguments "All"