-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.cake
82 lines (72 loc) · 2.32 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
#tool paket:?package=OpenCover
#tool paket:?package=codecov
#tool paket:?package=gitlink
#addin paket:?package=Cake.Paket
#addin paket:?package=Cake.Codecov
var target = Argument("target", "Build");
var configuration = Argument("Configuration", "Debug");
var version = EnvironmentVariable("GitVersion_NuGetVersion") ?? "0.0.0";
Task("CI")
.IsDependentOn("Pack")
.IsDependentOn("Codecov").Does(() => {});
Task("Pack")
.IsDependentOn("Build")
.Does(() => {
PaketPack("nugets", new PaketPackSettings {
Version = version
});
});
Task("Build")
.Does(() => {
DotNetCoreBuild("JsonLd.Entities.sln", new DotNetCoreBuildSettings {
Configuration = configuration
});
})
.DoesForEach(GetFiles("**/JsonLD.Entities.pdb"),
pdb => GitLink3(pdb, new GitLink3Settings {
RepositoryUrl = "https://github.com/wikibus/JsonLd.Entities",
}));
Task("Codecov")
.IsDependentOn("Test")
.Does(() => {
Codecov("opencover.xml");
});
Task("Test")
.IsDependentOn("Build")
.Does(() => {
var openCoverSettings = new OpenCoverSettings
{
OldStyle = true,
MergeOutput = true,
MergeByHash = true,
Register = "user",
ReturnTargetCodeOffset = 0
}
.WithFilter("+[JsonLD.Entities]*");
bool success = true;
foreach(var projectFile in new [] { "documentation.csproj", "jsonld.entities.tests.csproj" }.SelectMany(f => GetFiles($"**\\{f}")))
{
try
{
openCoverSettings.WorkingDirectory = projectFile.GetDirectory();
OpenCover(context => {
context.DotNetCoreTool(
projectPath: projectFile.FullPath,
command: "xunit",
arguments: $"-noshadow");
},
"opencover.xml",
openCoverSettings);
}
catch(Exception ex)
{
success = false;
Error("There was an error while running the tests", ex);
}
}
if(success == false)
{
throw new CakeException("There was an error while running the tests");
}
});
RunTarget(target);