-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbuild.cake
92 lines (78 loc) · 3.34 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
#l "common.cake"
//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
//////////////////////////////////////////////////////////////////////
// PREPARATION
//////////////////////////////////////////////////////////////////////
var buildNumber="0";
var versionNumber="1.4.0";
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 isRunningOnAppVeyor = AppVeyor.IsRunningOnAppVeyor;
if(isRunningOnAppVeyor)
buildNumber = AppVeyor.Environment.Build.Number.ToString();
var version = versionNumber + "." + buildNumber;
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("EnsureDependencies")
.Does(() =>
{
EnsureTool("dotnet", "--version");
});
Task("Clean")
.Does(() =>
{
CleanDirectory(buildDir);
CleanDirectory(distDir);
foreach(var directory in GetDirectories("src/**/bin"))
{
CleanDirectory(directory.FullPath);
}
foreach(var directory in GetDirectories("src/**/obj"))
{
CleanDirectory(directory.FullPath);
}
});
Task("Build")
.Does(() =>
{
ExecuteCommand("dotnet restore JavaScriptViewEngine.sln");
ExecuteCommand("dotnet build --configuration " + configuration + " --output " + buildDir + " /p:Version=" + versionNumber + " /p:FileVersion=" + version + " /p:AssemblyVersion=" + version + " JavaScriptViewEngine.sln");
});
Task("Deploy")
.Does(() =>
{
ExecuteCommand("dotnet publish --configuration " + configuration + " /p:Version=" + versionNumber + " /p:FileVersion=" + version + " /p:AssemblyVersion=" + version + " /t:pack src/JavaScriptViewEngine/JavaScriptViewEngine.csproj");
ExecuteCommand("dotnet publish --configuration " + configuration + " /p:Version=" + versionNumber + " /p:FileVersion=" + version + " /p:AssemblyVersion=" + version + " /t:pack src/JavaScriptViewEngine.Mvc5/JavaScriptViewEngine.Mvc5.csproj");
foreach(var package in GetFiles("src/JavaScriptViewEngine/bin/" + configuration + "/*.nupkg"))
{
CopyFile(package.FullPath, System.IO.Path.Combine(distDir, System.IO.Path.GetFileName(package.FullPath)));
}
foreach(var package in GetFiles("src/JavaScriptViewEngine.Mvc5/bin/" + configuration + "/*.nupkg"))
{
CopyFile(package.FullPath, System.IO.Path.Combine(distDir, System.IO.Path.GetFileName(package.FullPath)));
}
});
//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Task("Default")
.IsDependentOn("EnsureDependencies")
.IsDependentOn("Clean")
.IsDependentOn("Build");
Task("CI")
.IsDependentOn("EnsureDependencies")
.IsDependentOn("Clean")
.IsDependentOn("Build")
.IsDependentOn("Deploy");
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);