-
Notifications
You must be signed in to change notification settings - Fork 48
/
build.cake
119 lines (100 loc) · 3.29 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
#tool nuget:?package=NUnit.ConsoleRunner&version=3.4.0
#addin "Cake.FileHelpers"
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var platform = Argument("platform", "x86");
string version = Argument("vers", "");
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
// Define directories.
var buildDir = Directory("./SirenOfShame.WixSetup/bin") + Directory(configuration);
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.Does(() =>
{
CleanDirectories("./**/bin");
CleanDirectories("./**/obj");
});
Task("Restore-NuGet-Packages")
.IsDependentOn("Clean")
.Does(() =>
{
NuGetRestore("./SirenOfShame.sln");
});
Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
// Use MSBuild
MSBuild("./SirenOfShame.sln", settings => {
settings.WithProperty("Platform", platform);
settings.SetConfiguration(configuration);
});
});
Task("MakeMsi")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
// Use MSBuild
MSBuild("./SirenOfShame.WixSetup/SirenOfShame.WixSetup.wixproj", settings =>
{
settings.WithProperty("Platform", platform);
settings.SetConfiguration(configuration);
});
});
Task("SignMsi")
.IsDependentOn("MakeMsi")
.Does(() =>
{
var file = new FilePath("./SirenOfShame.WixSetup/bin/Release/SirenOfShame.WixSetup.msi");
Sign(file, new SignToolSignSettings {
CertSubjectName = "Open Source Developer, Lee RICHARDSON",
TimeStampUri = new Uri("http://time.certum.pl"),
DigestAlgorithm = SignToolDigestAlgorithm.Sha256,
Description = "Siren of Shame",
DescriptionUri = new Uri("https://sirenofshame.com")
});
});
Task("SetVersion")
.Does(() =>
{
if (string.IsNullOrEmpty(version)) {
throw new ArgumentNullException(nameof(version));
}
var versionRegex = "\"[1-9]+\\.[0-9]+\\.[0-9]+\"";
var newVersion = "\"" + version + "\"";
ReplaceRegexInFiles("./SirenOfShame/Properties/AssemblyInfo.cs", versionRegex, newVersion);
ReplaceRegexInFiles("./SirenOfShame.WixSetup/Product.wxs", versionRegex, newVersion);
});
// usage .\build.ps1 -t Publish -vers="2.4.12"
Task("Publish")
.IsDependentOn("SetVersion")
.IsDependentOn("SignMsi")
.Does(() =>
{
var versionWithDashes = version.Replace(".", "-");
MoveFile("./SirenOfShame.WixSetup/bin/Release/SirenOfShame.WixSetup.msi", $"./SirenOfShame.WixSetup/bin/Release/SirenOfShame-{versionWithDashes}.msi");
});
Task("Run-Unit-Tests")
.IsDependentOn("Build")
.Does(() =>
{
NUnit3("./src/**/bin/" + configuration + "/*.Tests.dll", new NUnit3Settings {
NoResults = true
});
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("Run-Unit-Tests");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);