This repository has been archived by the owner on Jul 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.fsx
155 lines (127 loc) · 5.06 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
#r "./packages/FAKE/tools/FakeLib.dll"
open Fake
open Fake.NuGet.Install
open System.IO
// Properties
let buildDir = "./build/"
let version = "0.0.2"
let wxsFile = "SetupTemplate.wxs"
Target "Clean" (fun _ ->
CleanDir buildDir
DeleteFile wxsFile
DeleteFile (wxsFile + ".wixobj")
)
Target "PurgeTestArtifacts" (fun _ ->
(* TODO Is there a better way to do this? I tried:
* DeleteFiles (!! buildDir + pattern).Includes
* but that gave me an illegal character in path exception.
*)
let deleteFiles pattern =
filesInDirMatching pattern (directoryInfo buildDir)
|> Seq.map (fun finfo -> finfo.FullName)
|> DeleteFiles
deleteFiles "*.Spec.*"
deleteFiles "*NUnit*"
deleteFiles "*nunit*"
deleteFiles "*NHamcrest*"
)
Target "RestorePackages" (fun _ ->
"src/Void.sln"
|> RestoreMSSolutionPackages (fun p ->
{ p with OutputPath = "src/packages" })
)
Target "Compile" (fun _ ->
!! "src/Void.sln"
|> MSBuildRelease buildDir "Build"
|> Log "Compile-Output: "
)
Target "Test" (fun _ ->
!! (buildDir + "*.Spec.dll")
|> NUnit (fun p ->
{ p with
DisableShadowCopy = true
OutputFile = buildDir + "TestResults.xml" })
)
Target "Rebuild" (fun _ ->
trace "Rebuild completed!"
)
Target "JustRunTests" (fun _ ->
trace "Test run completed!"
)
(* Got started with script from here:
* http://fsharp.github.io/FAKE/wix.html
* *)
Target "BuildWixInstall" (fun _ ->
(* This defines which files should be collected when running
* bulkComponentCreation *)
let fileFilter (file : FileInfo) =
file.Extension = ".dll" || file.Extension = ".exe" || file.Extension = ".config"
(* Collect Files which should be shipped. Pass directory with your
* deployment output for buildDir *)
let components = bulkComponentCreation fileFilter (DirectoryInfo buildDir)
(* Collect component references for usage in features *)
let componentRefs = components |> Seq.map (fun comp -> comp.ToComponentRef())
let completeFeature = generateFeatureElement (fun f ->
{f with
Id = "Complete"
Title = "Complete Feature"
Level = 1
Description = "Installs all features"
Components = componentRefs
Display = Expand
})
(* Generates a predefined WiX template with placeholders which will be
* replaced in "FillInWiXScript" *)
generateWiXScript wxsFile
let WiXUIMondo = generateUIRef (fun f -> {f with Id = "WixUI_Mondo" })
let WiXUIError = generateUIRef (fun f -> {f with Id = "WixUI_ErrorProgressText" })
let MajorUpgrade = generateMajorUpgradeVersion(
fun f ->
{f with
Schedule = MajorUpgradeSchedule.AfterInstallExecute
DowngradeErrorMessage = "A later version is already installed, exiting."
})
FillInWiXTemplate "" (fun f ->
{f with
ProductCode = System.Guid.NewGuid() // Guid which should be generated on every build
ProductName = "Void"
Description = "A fearless modern text editor in the spirit of Vim"
ProductLanguage = 1033
ProductVersion = version
ProductPublisher = "Polyglot Symposium"
UpgradeGuid = System.Guid.Parse "1b0f1b5e-90fd-4870-8a27-628f94f97d3b"
MajorUpgrade = [MajorUpgrade]
UIRefs = [WiXUIMondo; WiXUIError]
WiXVariables = [{ Id = "WixUILicenseRtf"; Overridable = YesOrNo.No; Value="LICENSE.rtf" }]
ProgramFilesFolder = ProgramFiles32
Components = components
BuildNumber = "0"
Features = [completeFeature]
})
(* Run the WiX tools *)
WiX (fun p -> {p with ToolDirectory = "packages/WiX/tools"}) (buildDir + "Void.msi") wxsFile
)
Target "RebuildMsi" (fun _ ->
trace "Build MSI completed!"
)
Target "WinCIBuild" (fun _ ->
trace "Windows CI build completed!"
)
// Dependencies
"Test"
==> "JustRunTests"
"Clean"
==> "RestorePackages"
==> "Compile"
==> "Rebuild"
"Test"
==> "Rebuild"
"Rebuild"
==> "RebuildMsi"
"PurgeTestArtifacts"
==> "BuildWixInstall"
==> "RebuildMsi"
"RebuildMsi"
==> "WinCIBuild"
// start build
RunTargetOrDefault "Rebuild"