forked from pauldotknopf/JavaScriptViewEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.cake
108 lines (91 loc) · 3.81 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
#l "common.cake"
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var versionPrefix = Argument("versionPrefix", "");
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
var buildNumber=1;
var baseDir=System.IO.Directory.GetCurrentDirectory();
var buildDir=System.IO.Path.Combine(baseDir, "build");
var distDir=System.IO.Path.Combine(baseDir, "dist");
var srcDir = System.IO.Path.Combine(baseDir, "src");
var srcProjectDir = System.IO.Path.Combine(srcDir, "JavaScriptViewEngine");
var srcProjectMvcCore1Dir = System.IO.Path.Combine(srcDir, "JavaScriptViewEngine.MvcCore1");
var srcProjectMvc5Dir = System.IO.Path.Combine(srcDir, "JavaScriptViewEngine.Mvc5");
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);
CleanDirectory(srcProjectMvcCore1Dir);
CleanDirectory(srcProjectMvc5Dir);
});
Task("PrepareMvc")
.Does(() =>
{
// We are going to copy src/JavaScriptViewEngine to src/JavaScriptViewEngine.MvcX/.
CopyDirectory(srcProjectDir, srcProjectMvcCore1Dir);
CopyDirectory(srcProjectDir, srcProjectMvc5Dir);
CopyFile(System.IO.Path.Combine(srcProjectDir, "project.mvccore1.json"), System.IO.Path.Combine(srcProjectMvcCore1Dir, "project.json"));
CopyFile(System.IO.Path.Combine(srcProjectDir, "project.mvc5.json"), System.IO.Path.Combine(srcProjectMvc5Dir, "project.json"));
});
Task("Build")
.Does(() =>
{
ExecuteCommand("dotnet restore src");
ExecuteCommand(string.Format("dotnet build \"src/JavaScriptViewEngine.MvcCore1/project.json\" --configuration \"{0}\"", configuration));
ExecuteCommand(string.Format("dotnet build \"src/JavaScriptViewEngine.Mvc5/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/JavaScriptViewEngine.MvcCore1/project.json\" --configuration \"{0}\" -o \"{1}\"", configuration, distDir, versionPrefix));
ExecuteCommand(string.Format("dotnet pack \"src/JavaScriptViewEngine.Mvc5/project.json\" --configuration \"{0}\" -o \"{1}\"", configuration, distDir, versionPrefix));
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("EnsureDependencies")
.IsDependentOn("Clean")
.IsDependentOn("PrepareMvc")
.IsDependentOn("Build")
.IsDependentOn("Test");
Task("CI")
.IsDependentOn("EnsureDependencies")
.IsDependentOn("Clean")
.IsDependentOn("PrepareMvc")
.IsDependentOn("Build")
.IsDependentOn("Test")
.IsDependentOn("Deploy");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);