This repository has been archived by the owner on Apr 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.cake
110 lines (95 loc) · 3.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
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
#tool "nuget:?package=GitVersion.CommandLine"
#addin "Cake.FileHelpers"
#addin "Cake.AWS.S3"
#tool "nuget:?package=OpenCover"
#tool "nuget:?package=ReportGenerator"
#tool "nuget:?package=coveralls.io"
#addin "nuget:?package=Cake.Coveralls"
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Debug");
var solution = GetFiles("*.sln").First();
//////////////////////////////////////////////////////////////////////
// APPVEYOR SETUP
//////////////////////////////////////////////////////////////////////
if(AppVeyor.IsRunningOnAppVeyor)
{
Setup(context =>
{
var settings = Context.CreateDownloadSettings().SetRegion("us-east-1").SetBucketName("levelup-pos-build");
System.Threading.Tasks.Task.WaitAll(new[]
{
// Configure nuget sources
S3Download(new FilePath(EnvironmentVariable("APPDATA") + "\\NuGet\\NuGet.Config"), "NuGet.Config", settings),
// Retrieve cert
S3Download(new FilePath(".\\BuildScripts\\Certificates.p12"), "Certificates.p12", settings)
});
// Pass version info to AppVeyor
GitVersion(new GitVersionSettings{
ArgumentCustomization = args => args.Append("-verbosity Warn"),
OutputType = GitVersionOutput.BuildServer,
NoFetch = true
});
});
}
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.Does(() =>
{
CleanDirectories("**/bin");
CleanDirectories("**/obj");
});
Task("Restore")
.IsDependentOn("Clean")
.Does(() =>
{
NuGetRestore(solution);
});
Task("Build")
.IsDependentOn("Restore")
.Does(() =>
{
MSBuild(solution, new MSBuildSettings {
Configuration = configuration,
EnvironmentVariables = new Dictionary<string, string>
{
{ "GitVersion_NoFetchEnabled", "true" }
},
ArgumentCustomization = arg => arg.AppendSwitch("/p:DebugType","=","Full")
});
});
Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
OpenCover(
tool => tool.DotNetCoreVSTest("**/bin/**/*Tests.dll"),
new FilePath("./coverage.xml"),
new OpenCoverSettings { ReturnTargetCodeOffset = 0, OldStyle = true }.WithFilter("+[*LevelUp*]LevelUp*").WithFilter("-[*Tests*]*")
);
if(AppVeyor.IsRunningOnAppVeyor)
{
CoverallsIo("./coverage.xml", new CoverallsIoSettings {
RepoToken = EnvironmentVariable("COVERALLS_TOKEN")
});
}
else
{
ReportGenerator("./coverage.xml", "./coverage", new ReportGeneratorSettings {
ReportTypes = new[] { ReportGeneratorReportType.HtmlSummary }
});
}
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("Test");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);