-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathbuild.cake
92 lines (77 loc) · 2.79 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
//////////////////////////////////////////////////////////////////////
// TOOLS
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
// Build Configuration
var configuration = EnvironmentVariable("CONFIGURATION") ?? "Release";
var isAppVeyorBuild = EnvironmentVariable("APPVEYOR") == "True";
var isPullRequest = EnvironmentVariable("APPVEYOR_PULL_REQUEST_NUMBER") != null;
// File/Directory paths
var artifactDirectory = MakeAbsolute(Directory("./artifacts")).FullPath;
var solutionFile = "./src/FileCache.sln";
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Clean")
.WithCriteria(!isAppVeyorBuild)
.Does(() =>
{
CleanDirectories(string.Format("./src/**/obj/{0}", configuration));
CleanDirectories(string.Format("./src/**/bin/{0}", configuration));
CleanDirectories("./artifacts");
});
Task("Restore-NuGet-Packages")
.Does(() =>
{
DotNetCoreRestore(solutionFile);
});
Task("Build")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
DotNetCoreBuild(solutionFile, new DotNetCoreBuildSettings
{
Configuration = Argument("configuration", configuration)
});
});
Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
DotNetCoreTest("./src/FileCache.UnitTests/FileCache.UnitTests.csproj", new DotNetCoreTestSettings{
Configuration = configuration,
//Logger = $"trx;LogFileName=TestResults.xml",
NoBuild = true, // Build will fail for the gitversion task, dotnet build does not yet play nicely with gitverion, until gitversion adds support
NoRestore = true
});
});
Task("Create-NuGet-Packages")
.WithCriteria(!isPullRequest)
.IsDependentOn("Build")
.Does(() =>
{
DotNetCorePack(solutionFile, new DotNetCorePackSettings
{
Configuration = configuration,
OutputDirectory = artifactDirectory
});
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("Clean")
.IsDependentOn("Restore-NuGet-Packages")
.IsDependentOn("Build")
.IsDependentOn("Test")
.IsDependentOn("Create-NuGet-Packages");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);