-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.cake
152 lines (133 loc) · 4.99 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
///////////////////////////////////////////////////////////////////////////////
// ARGUMENTS
///////////////////////////////////////////////////////////////////////////////
var target = Argument("target", "default");
var configuration = Argument("configuration", "Release");
var sln = "./back/Sequel/Sequel.sln";
var distDir = "./dist";
var distDirFullPath = MakeAbsolute(Directory($"{distDir}")).FullPath;
var publishDir = "./publish";
var publishDirFullPath = MakeAbsolute(Directory($"{publishDir}")).FullPath;
var winWarpPacker = "./build/warp/windows-x64.warp-packer.exe";
var linuxWarpPacker = "./build/warp/linux-x64.warp-packer";
var framework = "netcoreapp3.1";
var logger = Environment.GetEnvironmentVariable("TF_BUILD") == "True" ? $"-l:trx --results-directory {publishDirFullPath}" : "-l:console;verbosity=normal";
///////////////////////////////////////////////////////////////////////////////
// SETUP / TEARDOWN
///////////////////////////////////////////////////////////////////////////////
Setup(ctx =>
{
Information($"Building Sequel");
});
///////////////////////////////////////////////////////////////////////////////
// TASKS
///////////////////////////////////////////////////////////////////////////////
Task("clean").Does(() =>
{
CreateDirectory(distDir);
CleanDirectories(distDir);
CleanDirectories(publishDir);
CleanDirectories($"./**/obj/{framework}");
CleanDirectories(string.Format("./**/obj/{0}", configuration));
CleanDirectories(string.Format("./**/bin/{0}", configuration));
});
Task("install-vue-cli").Does(() =>
{
IEnumerable<string> standardOutput;
StartProcess("powershell", new ProcessSettings().SetRedirectStandardOutput(true).WithArguments
(
args => args.Append($"npm list -g @vue/cli")
), out standardOutput);
if (!string.Join(" ", standardOutput).Contains("@vue/cli"))
{
StartProcess("powershell", new ProcessSettings().WithArguments
(
args => args.Append($"npm install -g @vue/cli")
));
}
});
Task("npm-install-front").Does(() =>
{
StartProcess("powershell", new ProcessSettings().UseWorkingDirectory("./front").WithArguments
(
args => args.Append($"npm install")
));
});
Task("win-publish-front").WithCriteria(() => IsRunningOnWindows()).Does(() =>
{
StartProcess("powershell", new ProcessSettings().UseWorkingDirectory("./front").WithArguments
(
args => args.Append($"./node_modules/.bin/vue-cli-service build")
.Append($"--dest {publishDirFullPath}/app/win-x64/wwwroot")
.Append($"--target app")
.Append($"--mode production")
));
});
Task("linux-publish-front").WithCriteria(() => IsRunningOnUnix()).Does(() =>
{
StartProcess("powershell", new ProcessSettings().UseWorkingDirectory("./front").WithArguments
(
args => args.Append($"./node_modules/.bin/vue-cli-service build")
.Append($"--dest {publishDirFullPath}/app/linux-x64/wwwroot")
.Append($"--target app")
.Append($"--mode production")
));
});
Task("build-back").Does(() =>
{
DotNetCoreBuild(sln, new DotNetCoreBuildSettings
{
Configuration = configuration,
Verbosity = DotNetCoreVerbosity.Minimal
});
});
Task("win-publish-back").WithCriteria(() => IsRunningOnWindows()).Does(() =>
{
DotNetCorePublish("./back/Sequel/src/Sequel", new DotNetCorePublishSettings
{
Configuration = configuration,
OutputDirectory = publishDir + "/app/win-x64",
Runtime = "win-x64"
});
});
Task("linux-publish-back").WithCriteria(() => IsRunningOnUnix()).Does(() =>
{
DotNetCorePublish("./back/Sequel/src/Sequel", new DotNetCorePublishSettings
{
Configuration = configuration,
OutputDirectory = publishDir + "/app/linux-x64",
Runtime = "linux-x64"
});
});
Task("win-warp").WithCriteria(() => IsRunningOnWindows()).Does(() =>
{
StartProcess(winWarpPacker, new ProcessSettings().WithArguments
(
args => args.Append($"--arch windows-x64")
.Append($"--input_dir {publishDir}/app/win-x64")
.Append($"--exec Sequel.exe")
.Append($"--output {distDir}/sequel.exe")
));
});
Task("linux-warp").WithCriteria(() => IsRunningOnUnix()).Does(() =>
{
StartProcess(linuxWarpPacker, new ProcessSettings().WithArguments
(
args => args.Append($"--arch linux-x64")
.Append($"--input_dir {publishDir}/app/linux-x64")
.Append($"--exec Sequel")
.Append($"--output {distDir}/sequel")
));
});
Task("default")
.IsDependentOn("clean")
.IsDependentOn("install-vue-cli")
.IsDependentOn("npm-install-front")
.IsDependentOn("win-publish-front")
.IsDependentOn("linux-publish-front")
.IsDependentOn("build-back")
.IsDependentOn("win-publish-back")
.IsDependentOn("win-warp")
.IsDependentOn("linux-publish-back")
.IsDependentOn("linux-warp");
RunTarget(target);