-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
96 lines (80 loc) · 2.4 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
#tool nuget:?package=coveralls.io&version=1.4.2
#addin nuget:?package=Cake.Coveralls&version=1.0.0
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
const string solutionPath = "ApTest.sln";
const string projectPath = "ApTest/ApTest.csproj";
const string testProjectPath = "DummyTestProject/DummyTestProject.csproj";
const string packageOutputDirectory = "dist";
const string testReportDirectory = "TestsOutput";
const string coverageReportDirectory = "CoverageResults";
readonly string coverageReport = $"{coverageReportDirectory}/coverage.xml";
Task("Clean")
.Does(() =>
{
CleanDirectories("**/bin");
CleanDirectories("**/obj");
CleanDirectory(testReportDirectory);
CleanDirectory(coverageReportDirectory);
});
Task("Restore-Packages")
.IsDependentOn("Clean")
.Does(() =>
{
DotNetCoreRestore(solutionPath);
});
Task("Compile")
.IsDependentOn("Restore-Packages")
.Does(() =>
{
var settings = new DotNetCoreBuildSettings
{
Configuration = configuration,
Framework = "netstandard2.0"
};
DotNetCoreBuild(projectPath, settings);
});
Task("Test")
.IsDependentOn("Restore-Packages")
.Does(() =>
{
var settings = new DotNetCoreTestSettings
{
Configuration = configuration,
Framework = "netcoreapp5.0",
Loggers = new List<string>() { "trx" },
VSTestReportPath = $"{testReportDirectory}/report.trx"
};
settings.ArgumentCustomization =
args => args.Append("/p:CollectCoverage=true")
.Append($"/p:CoverletOutput=../{coverageReport}")
.Append("/p:CoverletOutputFormat=opencover")
.Append("/p:Exclude=[xunit.*]*");
DotNetCoreTest(testProjectPath, settings);
});
Task("Package")
.IsDependentOn("Restore-Packages")
.Does(() =>
{
var settings = new DotNetCorePackSettings
{
OutputDirectory = packageOutputDirectory,
Configuration = configuration
};
DotNetCorePack(projectPath, settings);
});
Task("Coverage-Report")
.IsDependentOn("Test")
.WithCriteria(BuildSystem.IsRunningOnAppVeyor)
.WithCriteria(() => FileExists(coverageReport))
.Does(() =>
{
var settings = new CoverallsIoSettings
{
RepoToken = EnvironmentVariable("CoverallsRepoToken")
};
CoverallsIo(coverageReport, settings);
});
Task("Default")
.IsDependentOn("Test");
RunTarget(target);