-
Notifications
You must be signed in to change notification settings - Fork 69
/
build.cake
84 lines (71 loc) · 2.44 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
var TARGET = Argument("t", Argument("target", "Default"));
var CONFIGURATION = Argument("c", Argument("configuration", "Release"));
var PREVIEW_LABEL = Argument ("previewLabel", EnvironmentVariable ("PREVIEW_LABEL") ?? "preview");
var BUILD_NUMBER = Argument ("buildNumber", EnvironmentVariable ("BUILD_NUMBER") ?? "0");
var GIT_SHA = Argument ("gitSha", EnvironmentVariable ("GIT_SHA") ?? "");
var GIT_BRANCH_NAME = Argument ("gitBranch", EnvironmentVariable ("GIT_BRANCH_NAME") ?? "");
Task("build")
.Does(() =>
{
var settings = new MSBuildSettings()
{ AllowPreviewVersion = true }
.EnableBinaryLogger("./output/binlogs/build.binlog")
.SetConfiguration(CONFIGURATION)
.SetMaxCpuCount(0)
.WithRestore();
MSBuild("./SkiaSharp.Extended.sln", settings);
});
Task("pack")
.Does(() =>
{
MSBuild("./SkiaSharp.Extended-Pack.slnf", new MSBuildSettings()
{ AllowPreviewVersion = true }
.EnableBinaryLogger("./output/binlogs/pack.binlog")
.SetConfiguration(CONFIGURATION)
.SetMaxCpuCount(0)
.WithRestore()
.WithProperty("PackageOutputPath", MakeAbsolute(new FilePath("./output/nugets")).FullPath)
.WithTarget("Pack"));
var preview = PREVIEW_LABEL;
if (!string.IsNullOrEmpty (BUILD_NUMBER)) {
preview += $".{BUILD_NUMBER}";
}
MSBuild("./SkiaSharp.Extended-Pack.slnf", new MSBuildSettings()
{ AllowPreviewVersion = true }
.EnableBinaryLogger("./output/binlogs/pack-preview.binlog")
.SetConfiguration(CONFIGURATION)
.SetMaxCpuCount(0)
.WithRestore()
.WithProperty("PackageOutputPath", MakeAbsolute(new FilePath("./output/nugets")).FullPath)
.WithProperty("VersionSuffix", preview)
.WithTarget("Pack"));
CopyFileToDirectory("./source/SignList.xml", "./output/nugets");
});
Task("test")
.Does(() =>
{
var failed = 0;
foreach (var csproj in GetFiles("./tests/*/*.csproj")) {
// skip WPF on non-Windows
if (!IsRunningOnWindows() && csproj.GetFilename().FullPath.Contains(".WPF."))
continue;
try {
DotNetTest(csproj.FullPath, new DotNetTestSettings {
Configuration = CONFIGURATION,
Loggers = new [] { $"trx;LogFileName={csproj.GetFilenameWithoutExtension()}.trx" },
});
} catch (Exception) {
failed++;
}
}
var output = $"./output/test-results/";
EnsureDirectoryExists(output);
CopyFiles($"./tests/**/TestResults/*.trx", output);
if (failed > 0)
throw new Exception($"{failed} tests have failed.");
});
Task("Default")
.IsDependentOn("build")
.IsDependentOn("pack")
.IsDependentOn("test");
RunTarget(TARGET);