-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.cake
120 lines (97 loc) · 3.2 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
#addin "nuget:?package=Cake.Coverlet&version=2.3.4"
#tool "nuget:?package=ReportGenerator&version=4.1.8"
#tool "nuget:?package=NUnit.Runners&version=2.6.4"
#tool "dotnet:?package=coverlet.console&version=1.5.1"
#module "nuget:?package=Cake.DotNetTool.Module&version=0.3.0"
var target = Argument("Target", "Default");
public class CurrentDirectory : System.IDisposable
{
readonly string _oldPath;
public CurrentDirectory(string path)
{
_oldPath = Environment.CurrentDirectory;
Environment.CurrentDirectory = path;
}
public void Dispose() => Environment.CurrentDirectory = _oldPath;
}
Task("NugetRestore")
.Does(() =>
{
NuGetRestore("./Xamarin.Forms.TestingLibrary.sln");
});
Task("BuildTest")
.IsDependentOn("NugetRestore")
.Does(() =>
{
DotNetCoreBuild("./test/Xamarin.Forms.TestingLibrary.Tests/Xamarin.Forms.TestingLibrary.Tests.csproj",
new DotNetCoreBuildSettings
{
Verbosity = DotNetCoreVerbosity.Minimal,
Configuration = "Debug",
NoRestore = true
});
});
Task("Test")
.IsDependentOn("BuildTest")
.Does(() =>
{
if (DirectoryExists(@".\coverage-results"))
{
DeleteDirectory(@".\coverage-results\", new DeleteDirectorySettings()
{
Recursive = true
});
}
var coverletSettings = new CoverletSettings {
CollectCoverage = true,
CoverletOutputFormat = CoverletOutputFormat.cobertura,
CoverletOutputDirectory = Directory(@".\coverage-results\"),
CoverletOutputName = $"results-{DateTime.UtcNow:dd-MM-yyyy-HH-mm-ss-FFF}",
Exclude = new List<string>
{
"[Xamarin.Forms.TestingLibrary.SampleApp]*"
}
};
Coverlet(
new FilePath("./test/Xamarin.Forms.TestingLibrary.Tests/Xamarin.Forms.TestingLibrary.Tests.csproj"),
coverletSettings);
});
Task("ReportGenerator")
.IsDependentOn("Test")
.Does(() => {
var reportGeneratorSettings = new ReportGeneratorSettings();
ReportGenerator("./coverage-results/*.xml", "./coverage-results/ReportGeneratorOutput", reportGeneratorSettings);
if (IsRunningOnUnix())
StartProcess("open", "./coverage-results/ReportGeneratorOutput/index.htm");
else
StartProcess("explorer", ".\\coverage-results\\ReportGeneratorOutput\\index.htm");
});
Task("Default")
.Does(() =>
{
});
Task("Clean")
.Does(() =>
{
var objFolders = GetDirectories("./src/**/obj*");
foreach (var objFolder in objFolders)
{
if (DirectoryExists(objFolder))
{
DeleteDirectory(objFolder, true);
}
}
var binFolders = GetDirectories("./src/**/bin*");
foreach (var binFolder in binFolders)
{
if (DirectoryExists(binFolder))
{
DeleteDirectory(binFolder, new DeleteDirectorySettings
{
Recursive = true,
Force = true
});
}
}
});
RunTarget(target);