forked from fsprojects/FSharp.Data
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.fsx
168 lines (139 loc) · 5.96 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
// --------------------------------------------------------------------------------------
// FAKE build script
// --------------------------------------------------------------------------------------
#r "paket: groupref fake //"
#if !FAKE
#load ".fake/build.fsx/intellisense.fsx"
#r "netstandard"
#endif
open System
open System.IO
open Fake.Core
open Fake.DotNet
open Fake.DotNet.NuGet
open Fake.DotNet.Testing
open Fake.IO
open Fake.IO.FileSystemOperators
open Fake.IO.Globbing.Operators
open Fake.Core.TargetOperators
open Fake.Tools.Git
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
let (!!) includes = (!! includes).SetBaseDirectory __SOURCE_DIRECTORY__
// --------------------------------------------------------------------------------------
// Information about the project to be used at NuGet and in AssemblyInfo files
// --------------------------------------------------------------------------------------
let project = "FSharp.Data"
let authors = "Tomas Petricek;Gustavo Guerra;Colin Bull;fsprojects contributors"
let summary = "Library of F# type providers and data access tools"
let description = """
The FSharp.Data package contains type providers and utilities to access
common data formats (CSV, HTML, JSON and XML in your F# applications and scripts. It also
contains helpers for parsing CSV, HTML and JSON files and for sending HTTP requests."""
let tags = "F# fsharp data typeprovider WorldBank CSV HTML CSS JSON XML HTTP linqpad-samples"
let gitOwner = "fsprojects"
let gitHome = "https://github.com/" + gitOwner
let gitName = "FSharp.Data"
let packageProjectUrl = "https://fsprojects.github.io/FSharp.Data/"
let repositoryType = "git"
let repositoryUrl = "https://github.com/fsprojects/FSharp.Data"
let license = "Apache-2.0"
// Read release notes & version info from RELEASE_NOTES.md
let release = ReleaseNotes.load "RELEASE_NOTES.md"
// --------------------------------------------------------------------------------------
// Generate assembly info files with the right version & up-to-date information
Target.create "AssemblyInfo" <| fun _ ->
for file in !! "src/AssemblyInfo*.fs" do
let replace (oldValue:string) newValue (str:string) = str.Replace(oldValue, newValue)
let title =
Path.GetFileNameWithoutExtension file
|> replace "AssemblyInfo" "FSharp.Data"
let versionSuffix =".0"
let version = release.AssemblyVersion + versionSuffix
AssemblyInfoFile.createFSharp file
[ AssemblyInfo.Title title
AssemblyInfo.Product project
AssemblyInfo.Description summary
AssemblyInfo.Version version
AssemblyInfo.FileVersion version]
// --------------------------------------------------------------------------------------
// Clean build results
Target.create "Clean" <| fun _ ->
seq {
yield! !!"**/bin"
yield! !!"**/obj"
} |> Shell.cleanDirs
Target.create "CleanDocs" <| fun _ ->
Shell.cleanDirs ["docs/output"]
let internetCacheFolder = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache)
Target.create "CleanInternetCaches" <| fun _ ->
Shell.cleanDirs [ internetCacheFolder @@ "DesignTimeURIs"
internetCacheFolder @@ "WorldBankSchema"
internetCacheFolder @@ "WorldBankRuntime"]
// --------------------------------------------------------------------------------------
// Build library & test projects
Target.create "Build" <| fun _ ->
"FSharp.Data.sln"
|> DotNet.build (fun o ->
{ o with Configuration = DotNet.BuildConfiguration.Release })
Target.create "RunTests" <| fun _ ->
"FSharp.Data.sln"
|> DotNet.test (fun o ->
{ o with Configuration = DotNet.BuildConfiguration.Release })
// --------------------------------------------------------------------------------------
// Build a NuGet package
Target.create "NuGet" <| fun _ ->
// Format the release notes
let releaseNotes = release.Notes |> String.concat "\n"
let properties = [
("Version", release.NugetVersion)
("Authors", authors)
("PackageProjectUrl", packageProjectUrl)
("PackageTags", tags)
("RepositoryType", repositoryType)
("RepositoryUrl", repositoryUrl)
("PackageLicenseExpression", license)
("PackageReleaseNotes", releaseNotes)
("Summary", summary)
("PackageDescription", description)
("EnableSourceLink", "true")
("PublishRepositoryUrl", "true")
("EmbedUntrackedSources", "true")
("IncludeSymbols", "true")
("SymbolPackageFormat", "snupkg")
]
DotNet.pack (fun p ->
{ p with
Configuration = DotNet.BuildConfiguration.Release
OutputPath = Some "bin"
MSBuildParams = { p.MSBuildParams with Properties = properties}
}
) "src/FSharp.Data/FSharp.Data.fsproj"
// --------------------------------------------------------------------------------------
// Generate the documentation
Target.create "GenerateDocs" (fun _ ->
Shell.cleanDir ".fsdocs"
DotNet.exec id "fsdocs" ("build --properties Configuration=Release --strict --eval --clean --parameters fsdocs-package-version " + release.NugetVersion) |> ignore
)
// --------------------------------------------------------------------------------------
// Help
Target.create "Help" <| fun _ ->
printfn ""
printfn " Please specify the target by calling 'build -t <Target>'"
printfn ""
printfn " Targets for building:"
printfn " * Build"
printfn " * RunTests"
printfn " * GenerateDocs"
printfn " * NuGet (creates package only, doesn't publish)"
printfn " * All (calls previous 5)"
printfn ""
printfn " Other targets:"
printfn " * CleanInternetCaches"
printfn ""
Target.create "All" ignore
"Clean" ==> "AssemblyInfo" ==> "Build"
"Build" ==> "CleanDocs" ==> "GenerateDocs" ==> "All"
"Build" ==> "NuGet" ==> "All"
"Build" ==> "All"
"Build" ==> "RunTests" ==> "All"
Target.runOrDefaultWithArguments "Help"