-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.fsx
164 lines (135 loc) · 4.58 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// -----------------------------------------------------------------------------
// FAKE build script
// -----------------------------------------------------------------------------
#if !FAKE
#r "Facades/netstandard"
#endif
#r "paket:
nuget Fake.Core.Target prerelease
nuget Fake.Core.ReleaseNotes
nuget Fake.DotNet.Cli
nuget Fake.DotNet.AssemblyInfoFile
nuget Fake.IO.FileSystem //"
#load "./.fake/build.fsx/intellisense.fsx"
open System
open System.IO
open Fake.Core
open Fake.Core.TargetOperators
open Fake.DotNet
open Fake.DotNet.NuGet
open Fake.IO
open Fake.IO.FileSystemOperators
open Fake.IO.Globbing.Operators
// -----------------------------------------------------------------------------
// Build Properties
// -----------------------------------------------------------------------------
type Project =
{ Name: string
Authors: string list
Summary: string
Guid: string }
let mainProject =
{ Name = "Irc.FSharp"
Summary = "An IRC client library for F#."
Authors = ["cagyirey"]
Guid = "694ab3b0-8929-4f78-ab72-55f29eb48a36" }
let configuration = DotNet.BuildConfiguration.Release
// publishable projects - for generated lib info
let projects = [ mainProject ]
let appReferences = !! "*.sln"
let testAssemblies = !! "tests/**/*.*proj"
let nuspecTemplates = !! "src/**/*.nuspec"
let releaseNotes = ReleaseNotes.parse (File.ReadLines "RELEASE_NOTES.md")
let tags = "irc ircv3"
let isAppveyorBuild = Environment.hasEnvironVar "APPVEYOR"
let appveyorBuildVersion = sprintf "%s-a%s" releaseNotes.AssemblyVersion (DateTime.UtcNow.ToString "yyMMddHHmm")
let nugetPublishParams (p: NuGet.NuGetParams) =
{ p with
Version = releaseNotes.AssemblyVersion
Tags = tags
Authors = mainProject.Authors
Project = mainProject.Name
Summary = mainProject.Summary
Description = mainProject.Summary
WorkingDir = "./"
OutputPath = "./publish"
ToolPath = "nuget"
PublishUrl = "https://api.nuget.org/v3/index.json"
//Publish=true
Files =
[ (@"src/Irc.FSharp/bin/Release/**/*.dll", Some "lib", None) ]
Dependencies =
[ "FParsec", NuGet.GetPackageVersion "./packages" "FParsec"]
}
// -----------------------------------------------------------------------------
// Custom Targets
// -----------------------------------------------------------------------------
Target.create "AppveyorBuildVersion" (fun _ ->
Shell.Exec("appveyor", sprintf "UpdateBuild -Version \"%s\"" appveyorBuildVersion) |> ignore
)
Target.create "AssemblyInfo" (fun _ ->
List.iter(fun project ->
let filename = "./src" @@ project.Name @@ "AssemblyInfo.fs"
AssemblyInfoFile.createFSharp filename
[ AssemblyInfo.Title project.Name
AssemblyInfo.Product project.Name
AssemblyInfo.Description project.Summary
AssemblyInfo.Version releaseNotes.AssemblyVersion
AssemblyInfo.FileVersion releaseNotes.AssemblyVersion
AssemblyInfo.Guid project.Guid ]) projects
)
Target.create "RunTests" (fun _ ->
testAssemblies
|> Seq.iter (DotNet.test (fun cfg ->
{ cfg with
NoBuild = true
Configuration = configuration
})
)
)
// -----------------------------------------------------------------------------
// Targets
// -----------------------------------------------------------------------------
Target.create "Clean" (fun _ ->
!! "src/**/bin"
++ "src/**/obj"
++ "test/**/bin"
++ "test/**/obj"
++ "publish"
|> Shell.cleanDirs
)
Target.create "Restore" (fun _ ->
appReferences
|> Seq.iter (fun p -> DotNet.restore id p)
)
Target.create "CopyLicense" (fun _ -> ()
// todo: implement this
)
Target.create "Build" (fun _ ->
appReferences
|> Seq.iter (DotNet.build (fun cfg ->
{ cfg with
Configuration = configuration
})
)
)
Target.create "NugetPublish" (fun _ ->
nuspecTemplates
|> Seq.iter (NuGet.NuGet nugetPublishParams)
)
Target.create "All" ignore
// -----------------------------------------------------------------------------
// Build order
// -----------------------------------------------------------------------------
"Clean"
=?> ("AppveyorBuildVersion", isAppveyorBuild)
==> "AssemblyInfo"
// paket restore is run by the build script and possibly netcore as well
// preferable to do it as a build task if other triggers can be disabled
// ==> "Restore"
==> "Build"
==> "RunTests"
==> "All"
"All"
==> "NuGetPublish"
Target.runOrDefaultWithArguments "All"