forked from xamarin/Essentials
-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.cake
91 lines (79 loc) · 2.31 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
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(() =>
{
// 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 {
DotNetCoreTest(csproj.FullPath, new DotNetCoreTestSettings {
Configuration = "Release",
Logger = $"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");
RunTarget(TARGET);