forked from jpdillingham/Soulseek.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
112 lines (99 loc) · 3.69 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
#load "build/Settings.cake"
#tool "nuget:?package=ReportGenerator&version=4.0.4"
#tool "nuget:?package=Codecov&version=1.1.0"
///////////////////////////////////////////////////////////////////////////////
// ARGUMENTS
///////////////////////////////////////////////////////////////////////////////
var target = Argument("target", "Build");
///////////////////////////////////////////////////////////////////////////////
// SETUP / TEARDOWN
///////////////////////////////////////////////////////////////////////////////
Setup<Settings>(ctx =>
{
var settings = new Settings(ctx, MakeAbsolute(Directory("./out")));;
Information("Cleaning up and ensuring directories exist...");
if(DirectoryExists(settings.BaseOutputDirectory))
DeleteDirectory(
settings.BaseOutputDirectory,
new DeleteDirectorySettings()
{
Recursive = true
}
);
foreach(var directory in settings.AllDirectories())
EnsureDirectoryExists(directory);
return settings;
});
///////////////////////////////////////////////////////////////////////////////
// TASKS
///////////////////////////////////////////////////////////////////////////////
// Until Coverlet supports merging as a single separate task instead of attaching it
// to the overarching coverage task
FilePath prevProject = null;
Task("TestWithCoverage")
.Does<Settings>(
settings =>
{
foreach(var currentProject in GetFiles("./tests/**/*.csproj"))
{
var dotnetTestSettings = new DotNetCoreTestSettings()
{
Logger = "trx",
ResultsDirectory = settings.TestResultsDirectory,
Configuration = "Release",
ArgumentCustomization = args =>
{
args.Append("/p:EnableCoverage=true");
args.Append("/p:CoverletOutputFormat=opencover");
if(prevProject != null)
args.Append($"/p:MergeWith=`{prevProject.GetDirectory().CombineWithFilePath("bin/cov/coverage.opencover.xml")}`");
return args;
}
};
DotNetCoreTest(currentProject.FullPath, dotnetTestSettings);
prevProject = currentProject;
}
Information($"Publishing test coverage results to '{settings.CoverageResultsDirectory}'...");
CopyFiles(prevProject.GetDirectory().FullPath + "/bin/cov/**/*",settings.CoverageResultsDirectory);
}
);
Task("GenerateCoverageReport")
.IsDependentOn("TestWithCoverage")
.Does<Settings>(
settings =>
{
ReportGenerator(
new [] { settings.CoverageResultsDirectory.CombineWithFilePath("coverage.opencover.xml")},
settings.CoverageReportDirectory.FullPath,
new ReportGeneratorSettings() {
ReportTypes = new [] { ReportGeneratorReportType.HtmlSummary, ReportGeneratorReportType.Html }
}
);
}
);
Task("Pack")
.Does<Settings>(
settings =>
{
DotNetCorePack(
"./src/Soulseek.NET/Soulseek.NET.csproj",
new DotNetCorePackSettings()
{
OutputDirectory = settings.PackageOutputDirectory,
Configuration = "Release"
}
);
}
);
///////////////////////////////////////////////////////////////////////////////
// Task Groups
// These are intended to be the major entrypoints of the build script.
///////////////////////////////////////////////////////////////////////////////
Task("Build")
.IsDependentOn("TestWithCoverage")
.IsDependentOn("Pack");
Task("BuildWithCoverageReport")
.IsDependentOn("TestWithCoverage")
.IsDependentOn("GenerateCoverageReport")
.IsDependentOn("Pack");
RunTarget(target);