-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
98 lines (86 loc) · 2.81 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
///////////////////////////////////////
// TOOLS
///////////////////////////////////////
#tool nuget:?package=NUnit.ConsoleRunner&version=3.4.0
///////////////////////////////////////
// ARGUMENTS
///////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
///////////////////////////////////////
// PATHS
///////////////////////////////////////
var assemblyInfoPath = File("./src/DiabloSpeech/Properties/AssemblyInfo.cs");
var solutionPath = File("./src/DiabloSpeech.sln");
var coreBuildDirectory = Directory("./src/DiabloSpeech.Core/bin") + Directory(configuration);
var buildDirectory = Directory("./src/DiabloSpeech/bin") + Directory(configuration);
var testPath = Directory("./tests/bin") + Directory(configuration) + File("tests.dll");
var stagingDirectory = Directory("./staging");
var packageBuildsDirectory = Directory("./builds");
var dependencies = "./dependencies/**/*.sln";
var dataDirectory = Directory("./data");
///////////////////////////////////////
// TASKS
///////////////////////////////////////
Task("Default")
.IsDependentOn("Package-Files");
Task("Clean")
.Does(() =>
{
CleanDirectory(buildDirectory);
CleanDirectory(stagingDirectory);
CleanDirectory(coreBuildDirectory);
EnsureDirectoryExists(packageBuildsDirectory);
});
Task("Restore-NuGet-Packages")
.IsDependentOn("Clean")
.Does(() =>
{
NuGetRestore(solutionPath);
NuGetRestore(GetFiles(dependencies));
});
Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
if (IsRunningOnWindows())
{
MSBuild(solutionPath, settings =>
settings.SetConfiguration(configuration));
}
else
{
XBuild(solutionPath, settings =>
settings.SetConfiguration(configuration));
}
});
Task("Run-Unit-Tests")
.IsDependentOn("Build")
.Does(() => NUnit3(testPath, new NUnit3Settings { NoResults = true }));
Task("Copy-Files")
.IsDependentOn("Run-Unit-Tests")
.Does(() =>
{
var path = buildDirectory.ToString();
var files = GetFiles(path + "/*.exe")
+ GetFiles(path + "/*.dll")
+ GetFiles(path + "/*.ico");
CopyFiles(files, stagingDirectory);
// Copy data directory files.
files = GetFiles(dataDirectory.ToString() + "/**/*");
CopyFiles(files, stagingDirectory);
});
Task("Package-Files")
.IsDependentOn("Copy-Files")
.Does(() =>
{
var assemblyInfo = ParseAssemblyInfo(assemblyInfoPath);
var packageName = "DiabloSpeech_" + assemblyInfo.AssemblyInformationalVersion + ".zip";
Zip(stagingDirectory, packageBuildsDirectory + File(packageName));
});
Task("CIntegration")
.IsDependentOn("Run-Unit-Tests");
///////////////////////////////////////
// EXECUTION
///////////////////////////////////////
RunTarget(target);