-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.fsx
121 lines (94 loc) · 3.15 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
#I @"Source\packages\Fake\tools"
#r "FakeLib.dll"
open Fake
(* properties *)
let authors = ["Max Malook, Marco Rasp, Stefan Senff"]
let projectName = "FeatureSwitcher.Contexteer"
TraceEnvironmentVariables()
let ReleaseCandidate = getBuildParamOrDefault "releaseCandidate" (System.DateTime.Now.ToString("yyyyMMddHHmmss"))
let NugetKey = getBuildParamOrDefault "nuget.key" ""
(* Directories *)
let sourceDir = "./Source/"
let packagesDir = sourceDir @@ "packages/"
let buildDir = "./Build/"
let testDir = buildDir
let testOutputDir = buildDir @@ "Specs/"
let nugetDir = buildDir @@ "NuGet/"
let deployDir = "./Release/"
(* files *)
let slnReferences = !! (sourceDir @@ "*.sln")
(* helper functions *)
let packageVersion() =
let projectAssembly = buildDir @@ (sprintf "%s.dll" projectName)
let assemblyName = System.Reflection.AssemblyName.GetAssemblyName(projectAssembly)
let version = assemblyName.Version.ToString(3)
if ReleaseCandidate = "false" then
version
else
sprintf "%s-rc%s" version ReleaseCandidate
let DependsOn package =
package, GetPackageVersion packagesDir package
(* Targets *)
Target "Clean" (fun _ ->
CleanDirs [buildDir; testDir; testOutputDir; nugetDir; deployDir]
)
Target "BuildApp" (fun _ ->
MSBuildRelease buildDir "Build" slnReferences
|> Log "AppBuild-Output: "
)
Target "Test" (fun _ ->
ActivateFinalTarget "DeployTestResults"
!! (testDir @@ "/*.Specs.dll")
|> MSpec (fun p ->
{p with
HtmlOutputDir = testOutputDir})
)
FinalTarget "DeployTestResults" (fun () ->
!! (testOutputDir @@ "/**/*.*")
|> Zip testOutputDir (deployDir @@ "MSpecResults.zip")
)
Target "BuildZip" (fun _ ->
!! (buildDir @@ sprintf "/%s.*" projectName)
-- "**/*Specs*"
|> Zip buildDir (deployDir @@ sprintf "%s-%s.zip" projectName (packageVersion()))
)
Target "BuildNuGet" (fun _ ->
let nugetLibDir = nugetDir @@ "lib" @@ "4.0"
CleanDirs [nugetLibDir]
!! (buildDir @@ sprintf "%s.dll" projectName)
++ (buildDir @@ sprintf "%s.xml" projectName)
|> CopyTo nugetLibDir
NuGet (fun p ->
{p with
Authors = authors
Project = projectName
Description = ""
Version = packageVersion()
Dependencies = [DependsOn "Contexteer"; DependsOn "FeatureSwitcher"]
OutputPath = nugetDir
WorkingDir = nugetDir
AccessKey = NugetKey
Publish = NugetKey <> "" })
(sourceDir @@ projectName @@ "Package.nuspec")
!! (nugetDir @@ sprintf "%s.*.nupkg" projectName)
|> CopyTo deployDir
)
Target "NotifyTeamCity" (fun _ ->
let setParameter name value =
sprintf "##teamcity[setParameter name='%s' value='%s']"
(EncapsulateSpecialChars name)
(EncapsulateSpecialChars value)
|> sendStrToTeamCity
setParameter "env.packageVersion" (packageVersion())
)
Target "Default" DoNothing
// Build order
"Clean"
==> "BuildApp"
==> "Test"
==> "BuildZip"
==> "BuildNuGet"
=?> ("NotifyTeamCity", TeamCity = buildServer)
==> "Default"
// start build
RunParameterTargetOrDefault "target" "Default"