forked from patriksvensson/ghostly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
127 lines (115 loc) · 4.43 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
#addin "nuget:?package=Cake.MinVer&version=2.0.0"
#load "eng/cake/utilities.cake"
using Spectre.Console;
var config = Argument("configuration", "Release");
var fullBuild = HasArgument("full");
var patchAppX = HasArgument("patch") ? true : fullBuild;
var platforms = fullBuild ? "x86|x64|arm|arm64" : "x86|x64|arm";
var artifacts = MakeAbsolute(new DirectoryPath("./.artifacts"));
var packages = artifacts.Combine("packages");
Teardown(ctx => {
Information("Shutting down .NET core SDK tooling...");
DotNetBuildServerShutdown(
new DotNetBuildServerShutdownSettings {
MSBuild = true
});
});
Task("Prereqs")
.WithCriteria(() => fullBuild, "Not running full build")
.Does(ctx =>
{
if (!FileExists(File("./src/Ghostly.GitHub/GitHubSecrets.Generated.cs"))) {
Error("GitHub OAUTH credentials have not been configured.");
Information("See README.md for more information.");
throw new CakeException("Build aborted");
}
});
Task("Clean")
.IsDependentOn("Prereqs")
.Does(ctx =>
{
CleanDirectory(artifacts);
CleanDirectory(packages);
});
Task("Restore")
.IsDependentOn("Clean")
.Does(ctx =>
{
MSBuild("./src/Ghostly.sln", new MSBuildSettings()
.WithTarget("Restore")
.SetConfiguration(config)
.SetVerbosity(Verbosity.Quiet)
.SetNoLogo(true)
.WithProperty("RestoreAdditionalProjectFallbackFolders", "")
.WithProperty("AppxBundle","Always")
.WithProperty("UapAppxPackageBuildMode", "StoreUpload")
.WithProperty("AppxBundlePlatforms", platforms)
.UseVSWhere(ctx));
});
Task("Patch-AppX-Info")
.WithCriteria(() => patchAppX, "Not running full build")
.IsDependentOn("Restore")
.Does(ctx =>
{
var version = MinVer();
var identity = fullBuild ? $"Ghostly" : "Ghostly_Dev";
var name = fullBuild ? $"Ghostly" : "Ghostly (Dev)";
var update = new Dictionary<string, string> {
{ "c:Package/c:Identity/@Name", fullBuild ? $"SpectreSystemsAB.Ghostly" : "SpectreSystemsAB.Ghostly.Dev"},
{ "c:Package/c:Applications/c:Application[1]/uap:VisualElements/@DisplayName", name },
{ "c:Package/c:Applications/c:Application[1]/uap:VisualElements/uap:DefaultTile/@ShortName", name },
{ "c:Package/c:Identity/@Version", $"{version.Major}.{version.Minor}.{version.Patch}.0" },
{ "c:Package/c:Identity/@Publisher", "CN=BD765503-99E8-40AA-91EC-B3E295890BB4" },
{ "c:Package/c:Applications/c:Application[1]/c:Extensions/uap5:Extension/uap5:StartupTask/@TaskId", identity },
{ "c:Package/c:Applications/c:Application[1]/c:Extensions/uap5:Extension/uap5:StartupTask/@DisplayName", name }
};
var manifest = File("./src/Ghostly.Uwp/Package.appxmanifest");
foreach(var item in update) {
XmlPoke(manifest, item.Key, item.Value,
new XmlPokeSettings {
Namespaces = {
{ "c", "http://schemas.microsoft.com/appx/manifest/foundation/windows10" },
{ "uap", "http://schemas.microsoft.com/appx/manifest/uap/windows10" },
{ "uap5", "http://schemas.microsoft.com/appx/manifest/uap/windows10/5" },
}
});
}
});
Task("Test")
.IsDependentOn("Restore")
.Does(ctx =>
{
var projects = GetFiles("./src/*.Tests/*.Tests.csproj");
foreach(var project in projects) {
AnsiConsole.WriteLine();
AnsiConsole.MarkupLine($"Running tests: [yellow]{project.GetFilename().FullPath}[/]");
DotNetTest(project.FullPath, new DotNetTestSettings {
Configuration = config,
NoRestore = true,
NoLogo = true,
Verbosity = DotNetVerbosity.Quiet,
});
}
});
Task("Build")
.IsDependentOn("Test")
.IsDependentOn("Patch-AppX-Info")
.Does(ctx =>
{
MSBuild("./src/Ghostly.sln", new MSBuildSettings()
.SetConfiguration(config)
.SetVerbosity(Verbosity.Quiet)
.SetNoLogo(true)
.UseToolVersion(MSBuildToolVersion.VS2022)
.SetMSBuildPlatform(MSBuildPlatform.x64)
.EnableBinaryLogger()
.WithProperty("RestoreAdditionalProjectFallbackFolders", "")
.WithProperty("AppxBundle","Always")
.WithProperty("UapAppxPackageBuildMode", "StoreUpload")
.WithProperty("AppxBundlePlatforms", platforms)
.SetUwpOutput(packages)
.UseNativeToolchain(fullBuild)
.BuildAppXBundle()
.UseVSWhere(ctx));
});
RunTarget(Argument("target", "Build"));