-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.cake
113 lines (100 loc) · 3.23 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
#tool "nuget:?package=JetBrains.dotCover.CommandLineTools&version=2019.2.3"
#tool "nuget:?package=xunit.runner.console&version=2.4.1"
#addin nuget:?package=Cake.GitVersioning&version=3.0.28
var target = Argument("target", "Default");
var buildConfiguration = Argument("configuration", "Release");
Task("Default")
.IsDependentOn("Pack")
.Does(() =>
{
});
Task("SetVersion")
.Does(() =>
{
TeamCity.SetBuildNumber(GitVersioningGetVersion().SemVer2);
});
Task("Restore")
.IsDependentOn("SetVersion")
.Does(() =>
{
var restoreSettings = new DotNetCoreRestoreSettings
{
Sources = new[] {"https://api.nuget.org/v3/index.json"}
};
DotNetCoreRestore("./src/NodaTime.Serialization.ServiceStackText.sln", restoreSettings);
});
Task("Build")
.IsDependentOn("Restore")
.Does(() =>
{
var buildSettings = new DotNetCoreBuildSettings
{
Configuration = buildConfiguration
};
DotNetCoreBuild("./src/NodaTime.Serialization.ServiceStackText.sln", buildSettings);
});
Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
Action<ICakeContext, string> runTests = (ctx, framework) => {
ctx.DotNetCoreTest("./src/NodaTime.Serialization.ServiceStackText.UnitTests/NodaTime.Serialization.ServiceStackText.UnitTests.csproj", new DotNetCoreTestSettings
{
Configuration = buildConfiguration,
Framework = framework,
NoBuild = true
});
};
var coverSettings = new DotCoverCoverSettings()
.WithFilter("-:xunit*")
.WithFilter("-:NuGet*")
.WithFilter("-:MSBuild*")
.WithFilter("-:*Tests")
.WithFilter("-:ServiceStack*")
.WithFilter("-:NodaTime")
.WithFilter("-:NodaTime.Testing");
var coverageResult452 = new FilePath("./dotcover/dotcover452.data");
DotCoverCover(
ctx => runTests(ctx, "net452"),
coverageResult452,
coverSettings);
var coverageResultCoreApp20 = new FilePath("./dotcover/dotcoverCoreApp20.data");
DotCoverCover(
ctx => runTests(ctx, "netcoreapp2.0"),
coverageResultCoreApp20,
coverSettings);
var mergedData = new FilePath("./dotcover/dotcoverMerged.data");
DotCoverMerge(
new []{
coverageResult452,
coverageResultCoreApp20
},
mergedData,
new DotCoverMergeSettings());
if(TeamCity.IsRunningOnTeamCity) {
TeamCity.ImportDotCoverCoverage(
mergedData,
MakeAbsolute(Directory("./tools/JetBrains.dotCover.CommandLineTools.2019.2.3/tools"))
);
}
else {
var htmlReportFile = new FilePath("./dotcover/dotcover.html");
var reportSettings = new DotCoverReportSettings { ReportType = DotCoverReportType.HTML};
DotCoverReport(mergedData, htmlReportFile, reportSettings);
StartProcess("powershell", "start file:///" + MakeAbsolute(htmlReportFile));
}
});
Task("Pack")
.IsDependentOn("Test")
.Does(() =>
{
var packSettings = new DotNetCorePackSettings
{
Configuration = buildConfiguration,
OutputDirectory = "./ReleasePackages/",
ArgumentCustomization = args => args.Append("--include-symbols")
.Append("--include-source")
};
DotNetCorePack("./src/NodaTime.Serialization.ServiceStackText/NodaTime.Serialization.ServiceStackText.csproj", packSettings);
});
RunTarget(target);