-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.cake
88 lines (72 loc) · 2.52 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
#l "common.cake"
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var versionPrefix = Argument("versionPrefix", "");
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
var buildNumber=9999;
var baseDir=System.IO.Directory.GetCurrentDirectory();
var buildDir=System.IO.Path.Combine(baseDir, "build");
var distDir=System.IO.Path.Combine(baseDir, "dist");
var isRunningOnAppVeyor = AppVeyor.IsRunningOnAppVeyor;
if(isRunningOnAppVeyor)
buildNumber = AppVeyor.Environment.Build.Number;
var version = buildNumber.ToString();
if(!string.IsNullOrEmpty(versionPrefix))
version = versionPrefix + "-" + version;
//System.Environment.SetEnvironmentVariable("DOTNET_BUILD_VERSION", version, System.EnvironmentVariableTarget.Process);
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("EnsureDependencies")
.Does(() =>
{
EnsureTool("dotnet", "--version");
});
Task("Clean")
.Does(() =>
{
CleanDirectory(buildDir);
CleanDirectory(distDir);
});
Task("Build")
.Does(() =>
{
ExecuteCommand("dotnet restore src");
ExecuteCommand(string.Format("dotnet build \"src/VroomJs/project.json\" --configuration \"{0}\"", configuration));
});
Task("Test")
.WithCriteria(() => !isRunningOnAppVeyor)
.Does(() =>
{
// no tests
});
Task("Deploy")
.Does(() =>
{
if(!DirectoryExists(distDir))
CreateDirectory(distDir);
ExecuteCommand(string.Format("dotnet pack \"src/VroomJs/project.json\" --configuration \"{0}\" -o \"{1}\"", configuration, distDir, versionPrefix));
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("EnsureDependencies")
.IsDependentOn("Clean")
.IsDependentOn("Build")
.IsDependentOn("Test");
Task("CI")
.IsDependentOn("EnsureDependencies")
.IsDependentOn("Clean")
.IsDependentOn("Build")
.IsDependentOn("Test")
.IsDependentOn("Deploy");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);