-
Notifications
You must be signed in to change notification settings - Fork 29
/
build.cake
109 lines (95 loc) · 2.96 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
var solution = File("./Bugsnag.sln");
var target = Argument("target", "Default");
var buildDir = Directory("./build");
var nugetPackageOutput = buildDir + Directory("packages");
var configuration = Argument("configuration", "Release");
var examples = GetFiles("./examples/**/*.sln");
var buildProps = File("./src/Directory.build.props");
string version = "1.0.0";
Task("Clean")
.Does(() => CleanDirectory(buildDir));
Task("Restore-NuGet-Packages")
.IsDependentOn("Clean")
.Does(() => NuGetRestore(solution));
Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() => {
MSBuild(solution, settings =>
settings
.WithProperty("BaseOutputPath", $"{MakeAbsolute(buildDir).FullPath}\\")
.SetVerbosity(Verbosity.Minimal)
.SetConfiguration(configuration));
});
Task("Test")
.IsDependentOn("Build")
.Does(() => {
var testAssemblies = GetFiles($"{buildDir}/**/*.Tests.dll");
var settings = new DotNetTestSettings
{
Configuration = configuration,
ArgumentCustomization = args => {
if (AppVeyor.IsRunningOnAppVeyor)
{
args.Append("-appveyor");
}
return args;
}
};
foreach(var file in testAssemblies)
{
DotNetTest(file.FullPath, "MSTest.MapInconclusiveToFailed=true", settings);
}
});
Task("Pack")
.IsDependentOn("Test")
.Does(() => {
MSBuild(solution, settings =>
settings
.SetVerbosity(Verbosity.Minimal)
.WithTarget("pack")
.SetConfiguration(configuration)
.WithProperty("IncludeSymbols", "true")
.WithProperty("SymbolPackageFormat", "snupkg")
.WithProperty("GenerateDocumentationFile", "true")
.WithProperty("PackageOutputPath", MakeAbsolute(nugetPackageOutput).FullPath));
});
Task("BuildExamples")
.Does(() => {
foreach (var example in examples) {
NuGetRestore(example);
MSBuild(example, settings =>
settings
.SetVerbosity(Verbosity.Minimal));
}
});
Task("SetVersion")
.Does(() => {
version = AppVeyor.Environment.Build.Version;
if (AppVeyor.Environment.Repository.Tag.IsTag)
{
version = AppVeyor.Environment.Repository.Tag.Name.TrimStart('v');
}
else
{
version = $"{version}-dev-{AppVeyor.Environment.Repository.Commit.Id.Substring(0, 7)}";
}
AppVeyor.UpdateBuildVersion(version);
var path = "/Project/PropertyGroup/Version";
XmlPoke(buildProps, path, version);
});
Task("MazeRunner")
.IsDependentOn("Pack")
.Does(() => {
StartProcess("cmd", "/c bundle install");
var mazeRunner = StartProcess("cmd", $"/c \"set BUGSNAG_VERSION={version} && bundle exec bugsnag-maze-runner --verbose\"");
if (mazeRunner != 0) {
throw new Exception("maze-runner failed");
}
});
Task("Default")
.IsDependentOn("Test");
Task("Appveyor")
.IsDependentOn("SetVersion")
.IsDependentOn("Pack")
.IsDependentOn("MazeRunner");
RunTarget(target);