This repository has been archived by the owner on May 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 505
/
build.cake
100 lines (85 loc) · 2.54 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
#addin "nuget:?package=Cake.Boots&version=1.1.0.712-preview2"
var TARGET = Argument("t", Argument("target", "ci"));
var NUGET_VERSION = EnvironmentVariable("NUGET_VERSION") ?? "1.0.0";
var GIT_SHA = Argument("gitSha", EnvironmentVariable("GIT_SHA") ?? "");
var GIT_BRANCH_NAME = Argument("gitBranch", EnvironmentVariable("GIT_BRANCH_NAME") ?? "");
Task("prepare")
.Does(async () =>
{
// Setup latest Xamarin.Android SDK
await Boots (Product.XamarinAndroid, ReleaseChannel.Stable);
// Update .csproj nuget versions
XmlPoke("./Xamarin.Essentials/Xamarin.Essentials.csproj", "/Project/PropertyGroup/PackageVersion", NUGET_VERSION);
});
Task("libs")
.IsDependentOn("prepare")
.Does(() =>
{
MSBuild("./Xamarin.Essentials/Xamarin.Essentials.csproj", new MSBuildSettings()
.EnableBinaryLogger("./output/binlogs/libs.binlog")
.SetConfiguration("Release")
.WithRestore());
});
Task("nugets")
.IsDependentOn("prepare")
.IsDependentOn("libs")
.IsDependentOn("docs")
.Does(() =>
{
MSBuild("./Xamarin.Essentials/Xamarin.Essentials.csproj", new MSBuildSettings()
.EnableBinaryLogger("./output/binlogs/nugets.binlog")
.SetConfiguration("Release")
.WithRestore()
.WithProperty("PackageOutputPath", MakeAbsolute(new FilePath("./output/")).FullPath)
.WithTarget("Pack"));
});
Task("tests")
.IsDependentOn("libs")
.Does(() =>
{
var failed = 0;
foreach (var csproj in GetFiles("./Tests/**/*.csproj")) {
try {
DotNetTest(csproj.FullPath, new DotNetTestSettings {
Configuration = "Release",
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("samples")
.IsDependentOn("nugets")
.Does(() =>
{
MSBuild("./Xamarin.Essentials.sln", new MSBuildSettings()
.EnableBinaryLogger("./output/binlogs/samples.binlog")
.SetConfiguration("Release")
.WithRestore());
});
Task("docs")
.IsDependentOn("libs")
.WithCriteria(IsRunningOnWindows())
.Does(() =>
{
MSBuild("./Xamarin.Essentials/Xamarin.Essentials.csproj", new MSBuildSettings()
.EnableBinaryLogger("./output/binlogs/docs.binlog")
.SetConfiguration("Release")
.WithRestore()
.WithTarget("mdocupdatedocs"));
});
Task("ci")
.IsDependentOn("libs")
.IsDependentOn("nugets")
.IsDependentOn("tests")
.IsDependentOn("samples");
Task("ci-release")
.IsDependentOn("libs")
.IsDependentOn("nugets");
RunTarget(TARGET);