-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
101 lines (84 loc) · 2.97 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
#tool "nuget:?package=xunit.runner.console"
#addin "nuget:?package=Cake.Incubator"
#tool "nuget:?package=coverlet.console"
#addin "nuget:?package=Cake.Coverlet"
#tool "nuget:?package=Codecov"
#addin "nuget:?package=Cake.Codecov"
var target = Argument("target", "Build");
public class BuildData
{
public DirectoryPath TestResultsDirectory;
public DirectoryPath CoverageResultsDirectory;
public DirectoryPath PackageDirectory;
public string Configuration;
public int BuildNumber;
}
Setup<BuildData>(ctx => new BuildData()
{
TestResultsDirectory = Directory(@"./.build/TestResults/"),
CoverageResultsDirectory = Directory(@"./.build/CoverageResults/"),
PackageDirectory = Directory(@"./.build/Packages/"),
Configuration = "Release",
BuildNumber = AppVeyor.IsRunningOnAppVeyor ? AppVeyor.Environment.Build.Number : 0
});
Task("Build")
.Does<BuildData>(data =>
{
CleanDirectory(data.PackageDirectory);
DotNetCoreBuild("src/SubEtha.sln", new DotNetCoreBuildSettings
{
Configuration = data.Configuration,
MSBuildSettings = new DotNetCoreMSBuildSettings
{
MaxCpuCount = 1
}
});
});
Task("NuGetPush")
.Does<BuildData>(data =>
{
if (!IsRunningOnWindows()) return;
var source = "https://www.nuget.org/api/v2/package";
var apiKey = Argument<string>("nugetapikey");
var pushSettings = new NuGetPushSettings {Source = source, ApiKey = apiKey};
// WARNING: this may publish more than we expect!
var packages = GetFiles($"{data.PackageDirectory}/Howatworks.*.nupkg");
NuGetPush(packages, pushSettings);
});
Task("Test")
.Does<BuildData>(data =>
{
CleanDirectory(data.TestResultsDirectory);
CleanDirectory(data.CoverageResultsDirectory);
var testSettings = new DotNetCoreTestSettings
{
NoBuild = true,
ResultsDirectory = data.TestResultsDirectory
};
foreach(var project in GetFiles("src/**/*Test.csproj"))
{
var coverletSettings = new CoverletSettings
{
CollectCoverage = true,
CoverletOutputFormat = CoverletOutputFormat.cobertura,
CoverletOutputDirectory = data.CoverageResultsDirectory,
CoverletOutputName = File($"Coverage.{project.GetFilenameWithoutExtension()}.cobertura.xml"),
};
DotNetCoreTest(project.FullPath, testSettings, coverletSettings);
}
});
Task("PublishCoverage")
.Does<BuildData>(data =>
{
var coverageFiles = GetFiles($"{data.CoverageResultsDirectory}/*.*");
if (AppVeyor.IsRunningOnAppVeyor)
{
Codecov(new CodecovSettings
{
Files = coverageFiles.Select(f => f.FullPath),
NoColor = true,
Required = true
});
}
});
RunTarget(target);