forked from fsprojects/FAKE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.fsx
238 lines (197 loc) · 8.18 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
#I @"tools/FAKE/tools/"
#r @"FakeLib.dll"
#load "tools/SourceLink.Fake/tools/SourceLink.fsx"
open Fake
open Fake.Git
open Fake.FSharpFormatting
open System.IO
open SourceLink
open Fake.ReleaseNotesHelper
// properties
let projectName = "FAKE"
let projectSummary = "FAKE - F# Make - Get rid of the noise in your build scripts."
let projectDescription = "FAKE - F# Make - is a build automation tool for .NET. Tasks and dependencies are specified in a DSL which is integrated in F#."
let authors = ["Steffen Forkmann"; "Mauricio Scheffer"; "Colin Bull"]
let mail = "[email protected]"
let gitRaw = environVarOrDefault "gitRaw" "https://raw.github.com/fsharp"
let release = parseReleaseNotes (System.IO.File.ReadAllLines "RELEASE_NOTES.md")
let packages =
["FAKE.Core",projectDescription
"FAKE.Gallio",projectDescription + " Extensions for Gallio"
"FAKE.IIS",projectDescription + " Extensions for IIS"
"FAKE.SQL",projectDescription + " Extensions for SQL Server"
"FAKE.Experimental",projectDescription + " Experimental Extensions"
"FAKE.Deploy.Lib",projectDescription + " Extensions for FAKE Deploy"
projectName,projectDescription + " This package bundles all extensions."]
let buildDir = "./build"
let testDir = "./test"
let deployDir = "./Publish"
let docsDir = "./docs"
let apidocsDir = "./docs/apidocs/"
let nugetDir = "./nuget"
let reportDir = "./report"
let deployZip = deployDir @@ sprintf "%s-%s.zip" projectName release.AssemblyVersion
let packagesDir = "./packages"
let additionalFiles = [
"License.txt"
"README.markdown"
"RELEASE_NOTES.md"
"help/changelog.md"]
// Targets
Target "Clean" (fun _ -> CleanDirs [buildDir; testDir; deployDir; docsDir; apidocsDir; nugetDir; reportDir])
Target "RestorePackages" RestorePackages
open Fake.AssemblyInfoFile
Target "SetAssemblyInfo" (fun _ ->
let common = [
Attribute.Product "FAKE - F# Make"
Attribute.Version release.AssemblyVersion
Attribute.InformationalVersion release.AssemblyVersion
Attribute.FileVersion release.AssemblyVersion]
[Attribute.Title "FAKE - F# Make Command line tool"
Attribute.Guid "fb2b540f-d97a-4660-972f-5eeff8120fba"] @ common
|> CreateFSharpAssemblyInfo "./src/app/FAKE/AssemblyInfo.fs"
[Attribute.Title "FAKE - F# Make Deploy tool"
Attribute.Guid "413E2050-BECC-4FA6-87AA-5A74ACE9B8E1"] @ common
|> CreateFSharpAssemblyInfo "./src/app/Fake.Deploy/AssemblyInfo.fs"
[Attribute.Title "FAKE - F# Make Deploy Web"
Attribute.Guid "27BA7705-3F57-47BE-B607-8A46B27AE876"] @ common
|> CreateFSharpAssemblyInfo "./src/deploy.web/Fake.Deploy.Web/AssemblyInfo.fs"
[Attribute.Title "FAKE - F# Make Deploy Lib"
Attribute.Guid "AA284C42-1396-42CB-BCAC-D27F18D14AC7"] @ common
|> CreateFSharpAssemblyInfo "./src/app/Fake.Deploy.Lib/AssemblyInfo.fs"
[Attribute.Title "FAKE - F# Make Lib"
Attribute.InternalsVisibleTo "Test.FAKECore"
Attribute.Guid "d6dd5aec-636d-4354-88d6-d66e094dadb5"] @ common
|> CreateFSharpAssemblyInfo "./src/app/FakeLib/AssemblyInfo.fs"
[Attribute.Title "FAKE - F# Make SQL Lib"
Attribute.Guid "A161EAAF-EFDA-4EF2-BD5A-4AD97439F1BE"] @ common
|> CreateFSharpAssemblyInfo "./src/app/Fake.SQL/AssemblyInfo.fs"
[Attribute.Title "FAKE - F# Make Experimental Lib"
Attribute.Guid "5AA28AED-B9D8-4158-A594-32FE5ABC5713"] @ common
|> CreateFSharpAssemblyInfo "./src/app/Fake.Experimental/AssemblyInfo.fs"
)
Target "BuildSolution" (fun _ ->
MSBuildWithDefaults "Build" ["./FAKE.sln"; "./FAKE.Deploy.Web.sln"]
|> Log "AppBuild-Output: "
)
Target "GenerateDocs" (fun _ ->
let source = "./help"
let template = "./help/literate/templates/template-project.html"
let templatesDir = "./help/templates/reference/"
let githubLink = "https://github.com/fsharp/FAKE"
let projInfo =
[ "page-description", "FAKE - F# Make"
"page-author", separated ", " authors
"project-author", separated ", " authors
"github-link", githubLink
"project-github", "http://github.com/fsharp/fake"
"project-nuget", "https://www.nuget.org/packages/FAKE"
"root", "http://fsharp.github.io/FAKE"
"project-name", "FAKE - F# Make" ]
CreateDocs source docsDir template projInfo
let dllFiles =
!! "./build/**/Fake.*.dll"
++ "./build/FakeLib.dll"
-- "./build/**/Fake.Experimental.dll"
-- "./build/**/Fake.Deploy.Lib.dll"
CreateDocsForDlls apidocsDir templatesDir projInfo (githubLink + "/blob/develop") dllFiles
WriteStringToFile false "./docs/.nojekyll" ""
CopyDir (docsDir @@ "content") "help/content" allFiles
CopyDir (docsDir @@ "pics") "help/pics" allFiles
)
Target "CopyLicense" (fun _ ->
CopyTo buildDir additionalFiles
)
Target "Test" (fun _ ->
let dlls = !! (testDir @@ "Test.*.dll")
dlls
|> MSpec (fun p ->
{p with
ExcludeTags = ["HTTP"]
HtmlOutputDir = reportDir})
dlls
|> xUnit (fun p -> p)
)
Target "SourceLink" (fun _ ->
use repo = new GitRepo(__SOURCE_DIRECTORY__)
!! "src/app/**/*.fsproj"
|> Seq.iter (fun f ->
let proj = VsProj.LoadRelease f
logfn "source linking %s" proj.OutputFilePdb
let files = proj.Compiles -- "**/AssemblyInfo.fs"
repo.VerifyChecksums files
proj.VerifyPdbChecksums files
proj.CreateSrcSrv (sprintf "%s/%s/{0}/%%var2%%" gitRaw projectName) repo.Revision (repo.Paths files)
Pdbstr.exec proj.OutputFilePdb proj.OutputFilePdbSrcSrv
)
)
Target "CreateNuGet" (fun _ ->
for package,description in packages do
let nugetDocsDir = nugetDir @@ "docs"
let nugetToolsDir = nugetDir @@ "tools"
CleanDir nugetDocsDir
CleanDir nugetToolsDir
DeleteFile "./build/FAKE.Gallio/Gallio.dll"
match package with
| p when p = projectName ->
!! (buildDir @@ "**/*.*") |> Copy nugetToolsDir
CopyDir nugetToolsDir @"./lib/fsi" allFiles
CopyDir nugetDocsDir docsDir allFiles
| p when p = "FAKE.Core" ->
!! (buildDir @@ "*.*") |> Copy nugetToolsDir
CopyDir nugetToolsDir @"./lib/fsi" allFiles
CopyDir nugetDocsDir docsDir allFiles
| _ ->
CopyDir nugetToolsDir (buildDir @@ package) allFiles
CopyTo nugetToolsDir additionalFiles
!! (nugetToolsDir @@ "*.pdb") |> DeleteFiles
NuGet (fun p ->
{p with
Authors = authors
Project = package
Description = description
Version = release.NugetVersion
OutputPath = nugetDir
Summary = projectSummary
ReleaseNotes = release.Notes |> toLines
Dependencies =
if package <> "FAKE.Core" && package <> projectName then
["FAKE.Core", RequireExactly (NormalizeVersion release.AssemblyVersion)]
else p.Dependencies
AccessKey = getBuildParamOrDefault "nugetkey" ""
Publish = hasBuildParam "nugetkey"
ToolPath = "./tools/NuGet/nuget.exe" }) "fake.nuspec"
)
Target "ReleaseDocs" (fun _ ->
CleanDir "gh-pages"
cloneSingleBranch "" "https://github.com/fsharp/FAKE.git" "gh-pages" "gh-pages"
fullclean "gh-pages"
CopyRecursive "docs" "gh-pages" true |> printfn "%A"
CopyFile "gh-pages" "./Samples/FAKE-Calculator.zip"
StageAll "gh-pages"
Commit "gh-pages" (sprintf "Update generated documentation %s" release.NugetVersion)
Branches.push "gh-pages"
)
Target "Release" (fun _ ->
StageAll ""
Commit "" (sprintf "Bump version to %s" release.NugetVersion)
Branches.push ""
Branches.tag "" release.NugetVersion
Branches.pushTag "" "origin" release.NugetVersion
)
Target "Default" DoNothing
// Dependencies
"Clean"
==> "RestorePackages"
==> "SetAssemblyInfo"
==> "BuildSolution"
==> "Test"
==> "Default"
==> "CopyLicense"
=?> ("GenerateDocs", isLocalBuild && not isLinux)
=?> ("SourceLink", isLocalBuild && not isLinux)
=?> ("CreateNuGet", not isLinux)
=?> ("ReleaseDocs", isLocalBuild && not isLinux)
==> "Release"
// start build
RunTargetOrDefault "Default"