forked from MathewSachin/Captura
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.cake
151 lines (124 loc) · 3.98 KB
/
build.cake
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
#tool nuget:?package=xunit.runner.console&version=2.4.1
#l "scripts/backup.cake"
#l "scripts/constants.cake"
#l "scripts/choco.cake"
#l "scripts/apikeys.cake"
#l "scripts/version.cake"
using System.Collections.Generic;
#region Fields
readonly var target = Argument("target", "Default");
readonly var configuration = Argument("configuration", Release);
#endregion
#region Functions
void PopulateOutput()
{
// Copy License files
CopyDirectory(licensesFolder, distFolder + Directory("licenses"));
var consoleBinFolder = sourceFolder + Directory("Captura.Console/bin") + Directory(configuration);
var uiBinFolder = sourceFolder + Directory("Captura/bin") + Directory(configuration);
// Copy Languages
CopyDirectory(uiBinFolder + Directory("Languages"), distFolder + Directory("languages"));
// Copy executables and config files
CopyFiles(consoleBinFolder.Path + "/*.exe*", distFolder);
CopyFiles(uiBinFolder.Path + "/*.exe*", distFolder);
// Copy Keymap files
CopyDirectory(uiBinFolder + Directory("keymaps"), distFolder + Directory("keymaps"));
// For Debug builds
if (configuration != Release)
{
// Assemblies, Symbol Files and XML Documentation
foreach (var extension in new [] { ".dll", ".pdb", ".xml" })
{
CopyFiles(consoleBinFolder.Path + "/*" + extension, distFolder);
CopyFiles(uiBinFolder.Path + "/*" + extension, distFolder);
}
}
else
{
CopyDirectory(consoleBinFolder + Directory("lib"), distFolder + Directory("lib"));
CopyDirectory(uiBinFolder + Directory("lib"), distFolder + Directory("lib"));
}
}
void PackPortable()
{
// Portable build directories
var settingsDir = distFolder + Directory("Settings");
var codecsDir = distFolder + Directory("Codecs");
CreateDirectory(settingsDir);
CreateDirectory(codecsDir);
Zip(distFolder, PortablePath);
var dirDeleteSettings = new DeleteDirectorySettings {
Recursive = true,
Force = true
};
DeleteDirectory(settingsDir, dirDeleteSettings);
DeleteDirectory(codecsDir, dirDeleteSettings);
}
#endregion
#region Setup / Teardown
Setup(context =>
{
EnsureDirectoryExists(tempFolder);
EnsureDirectoryExists(distFolder);
HandleVersion();
if (configuration == Release)
{
EmbedApiKeys();
}
});
Teardown(context =>
{
RestoreBackups();
});
#endregion
#region Tasks
var buildTask = Task("Build")
.Does(() =>
{
MSBuild(slnPath, settings =>
{
settings.SetConfiguration(configuration)
.SetVerbosity(Verbosity.Minimal)
.WithTarget("Rebuild")
.WithRestore()
.UseToolVersion(MSBuildToolVersion.VS2019);
});
});
var cleanOutputTask = Task("Clean-Output").Does(() => CleanDirectory(distFolder));
var populateOutputTask = Task("Populate-Output")
.IsDependentOn(cleanOutputTask)
.IsDependentOn(buildTask)
.Does(() => PopulateOutput());
var packPortableTask = Task("Pack-Portable")
.IsDependentOn(populateOutputTask)
.Does(() => PackPortable());
var packSetupTask = Task("Pack-Setup")
.IsDependentOn(populateOutputTask)
.Does(() =>
{
const string InnoScriptPath = "Inno.iss";
InnoSetup(InnoScriptPath, new InnoSetupSettings
{
QuietMode = InnoSetupQuietMode.Quiet,
ArgumentCustomization = Args => Args.Append($"/DMyAppVersion={version}")
});
});
var packChocoTask = Task("Pack-Choco")
.IsDependentOn(packPortableTask)
.Does(() => PackChoco());
var testTask = Task("Test")
.IsDependentOn(buildTask)
.Does(() => XUnit2(sourceFolder + File($"Tests/bin/{configuration}/**/Captura.Tests.dll")));
var defaultTask = Task("Default")
.IsDependentOn(packPortableTask)
.IsDependentOn(packSetupTask)
.IsDependentOn(packChocoTask);
#endregion
Task("CI")
.IsDependentOn(testTask)
.IsDependentOn(packPortableTask)
.IsDependentOn(packSetupTask)
.IsDependentOn(packChocoTask)
.Does(() => { });
// Start
RunTarget(target);