-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.fsx
154 lines (136 loc) · 4.33 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
// include Fake lib
#r "tools/FAKE/tools/FakeLib.dll"
open Fake
open Fake.AssemblyInfoFile
open Fake.Testing.NUnit3
open System
open System.IO
let authors = ["@minton"; "@hotgazpacho"; "@brycekbargar"]
let projectName = "Binda"
let projectDescription = "Smart WinForms Data Binding"
let debugDir = __SOURCE_DIRECTORY__ + @"\src\binda\bin\Debug\"
let releaseDir = __SOURCE_DIRECTORY__ + @"\src\binda\bin\Release\"
//Hard coded paths since f# via FAKE always returns x86 ProgramFiles
let nunit = __SOURCE_DIRECTORY__ + @"\src\packages\NUnit.ConsoleRunner.3.7.0\tools\nunit3-console.exe"
let packages = __SOURCE_DIRECTORY__ + @"\src\packages"
let version = getBuildParamOrDefault "ver" "0.0.1"
let testAssemblies = !! (@"src\binda.tests\bin\Debug\binda.tests.dll")
let packagingRoot = "./packaging/"
let packagingDir = packagingRoot @@ "binda"
let releaseNotes =
ReadFile "ReleaseNotes.md"
|> ReleaseNotesHelper.parseReleaseNotes
//Helper
let rec getAllFiles dir pattern =
seq { yield! Directory.EnumerateFiles(dir, pattern)
for d in Directory.EnumerateDirectories(dir) do
yield! getAllFiles d pattern }
//Restore Nuget stuff
Target "RestorePackages" (fun _ ->
"./src/binda.sln"
|> RestoreMSSolutionPackages (fun _ ->
RestorePackageDefaults)
)
// Clean out the directories
Target "Clean" (fun _ ->
CleanDirs [debugDir; releaseDir; packagingRoot; packagingDir;]
CopyFile packagingDir "ReleaseNotes.md"
let setParams defaults =
{ defaults with
Verbosity = Some(Quiet)
Targets = ["Clean"]
Properties =
[
"Configuration", "Release"
]
}
build setParams "./src/binda.sln"
let setParams defaults =
{ defaults with
Verbosity = Some(Quiet)
Targets = ["Clean"]
Properties =
[
"Configuration", "Debug"
]
}
build setParams "./src/binda.sln"
)
//Update version info before building
Target "UpdateAssemblyInfo" (fun _ ->
let csharpAssemblyInfos = getAllFiles __SOURCE_DIRECTORY__ "AssemblyInfo.cs"
let assemblyAttributes = [Attribute.Title projectName
Attribute.Description projectDescription
Attribute.Version version
Attribute.FileVersion version]
csharpAssemblyInfos
|> Seq.iter (fun i -> UpdateAttributes i assemblyAttributes)
)
Target "BuildRelease" (fun _ ->
let setParams defaults =
{ defaults with
Verbosity = Some(Quiet)
Targets = ["Build"]
Properties =
[
"Optimize", "True"
"DebugSymbols", "True"
"Configuration", "Release"
]
}
build setParams "./src/binda.sln"
)
Target "BuildAppDebug" (fun _ ->
let setParams defaults =
{ defaults with
Verbosity = Some(Quiet)
Targets = ["Build"]
Properties =
[
"Configuration", "Debug"
]
}
build setParams "./src/binda.sln"
)
Target "NUnitTests" (fun _ ->
testAssemblies
|> NUnit3 (fun p ->
{ p with
TimeOut = TimeSpan.FromMinutes 20. })
)
Target "BuildAndTest" (fun _ ->
trace "Built and ran tests."
)
Target "CreatePackage" (fun _ ->
let netDir = packagingDir @@ "lib/net45/"
CleanDir netDir
CopyFile netDir (releaseDir @@ "Binda.dll")
CopyFile netDir (releaseDir @@ "Inflector.dll")
let key = environVarOrFail "nugetkey"
NuGet (fun p ->
{p with
Authors = authors
Project = projectName
Description = projectDescription
OutputPath = packagingRoot
Summary = projectDescription
WorkingDir = packagingDir
Version = version
ReleaseNotes = toLines releaseNotes.Notes
AccessKey = key
Publish = true }) "binda.nuspec"
)
// Dependencies
"Clean"
==> "RestorePackages"
==> "UpdateAssemblyInfo"
==> "BuildRelease"
"Clean"
==> "RestorePackages"
==> "BuildAppDebug"
==> "NUnitTests"
==> "BuildAndTest"
"BuildRelease"
==> "CreatePackage"
// default task
RunTargetOrDefault "BuildAndTest"