zarro 1.99.2 → 1.99.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gulp-tasks/build.js +157 -135
- package/gulp-tasks/modules/register-environment-variables.js +532 -526
- package/gulp-tasks/test-dotnet.js +196 -196
- package/package.json +1 -1
package/gulp-tasks/build.js
CHANGED
|
@@ -1,135 +1,157 @@
|
|
|
1
|
-
const
|
|
2
|
-
chalk = require("ansi-colors"),
|
|
3
|
-
os = require("os"),
|
|
4
|
-
env = requireModule("env"),
|
|
5
|
-
gulp = requireModule("gulp"),
|
|
6
|
-
debug = require("debug")("build"),
|
|
7
|
-
promisifyStream = requireModule("promisify"),
|
|
8
|
-
dotnetCli = require("gulp-dotnet-cli"),
|
|
9
|
-
dotnetClean = dotnetCli.clean,
|
|
10
|
-
dotnetBuild = dotnetCli.build,
|
|
11
|
-
throwIfNoFiles = requireModule("throw-if-no-files"),
|
|
12
|
-
xbuild = requireModule("gulp-xbuild"),
|
|
13
|
-
gutil = requireModule("gulp-util"),
|
|
14
|
-
log = requireModule("log"),
|
|
15
|
-
resolveMasks = requireModule("resolve-masks"),
|
|
16
|
-
logConfig = requireModule("log-config"),
|
|
17
|
-
msbuild = require("gulp-msbuild");
|
|
18
|
-
|
|
19
|
-
gulp.task("prebuild", ["nuget-restore"]);
|
|
20
|
-
|
|
21
|
-
const myTasks = ["build"],
|
|
22
|
-
myVars = [
|
|
23
|
-
"BUILD_CONFIGURATION",
|
|
24
|
-
"BUILD_PLATFORM",
|
|
25
|
-
"BUILD_ARCHITECTURE",
|
|
26
|
-
"BUILD_TARGETS",
|
|
27
|
-
"BUILD_TOOLSVERSION",
|
|
28
|
-
"BUILD_VERBOSITY",
|
|
29
|
-
"BUILD_MSBUILD_NODE_REUSE",
|
|
30
|
-
"BUILD_MAX_CPU_COUNT",
|
|
31
|
-
"MAX_CONCURRENCY",
|
|
32
|
-
"BUILD_INCLUDE",
|
|
33
|
-
"BUILD_EXCLUDE",
|
|
34
|
-
"BUILD_ADDITIONAL_EXCLUDE",
|
|
35
|
-
"BUILD_SHOW_INFO",
|
|
36
|
-
"BUILD_FAIL_ON_ERROR"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
const
|
|
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
|
-
|
|
1
|
+
const
|
|
2
|
+
chalk = require("ansi-colors"),
|
|
3
|
+
os = require("os"),
|
|
4
|
+
env = requireModule("env"),
|
|
5
|
+
gulp = requireModule("gulp"),
|
|
6
|
+
debug = require("debug")("build"),
|
|
7
|
+
promisifyStream = requireModule("promisify"),
|
|
8
|
+
dotnetCli = require("gulp-dotnet-cli"),
|
|
9
|
+
dotnetClean = dotnetCli.clean,
|
|
10
|
+
dotnetBuild = dotnetCli.build,
|
|
11
|
+
throwIfNoFiles = requireModule("throw-if-no-files"),
|
|
12
|
+
xbuild = requireModule("gulp-xbuild"),
|
|
13
|
+
gutil = requireModule("gulp-util"),
|
|
14
|
+
log = requireModule("log"),
|
|
15
|
+
resolveMasks = requireModule("resolve-masks"),
|
|
16
|
+
logConfig = requireModule("log-config"),
|
|
17
|
+
msbuild = require("gulp-msbuild");
|
|
18
|
+
|
|
19
|
+
gulp.task("prebuild", ["nuget-restore"]);
|
|
20
|
+
|
|
21
|
+
const myTasks = ["build"],
|
|
22
|
+
myVars = [
|
|
23
|
+
"BUILD_CONFIGURATION",
|
|
24
|
+
"BUILD_PLATFORM",
|
|
25
|
+
"BUILD_ARCHITECTURE",
|
|
26
|
+
"BUILD_TARGETS",
|
|
27
|
+
"BUILD_TOOLSVERSION",
|
|
28
|
+
"BUILD_VERBOSITY",
|
|
29
|
+
"BUILD_MSBUILD_NODE_REUSE",
|
|
30
|
+
"BUILD_MAX_CPU_COUNT",
|
|
31
|
+
"MAX_CONCURRENCY",
|
|
32
|
+
"BUILD_INCLUDE",
|
|
33
|
+
"BUILD_EXCLUDE",
|
|
34
|
+
"BUILD_ADDITIONAL_EXCLUDE",
|
|
35
|
+
"BUILD_SHOW_INFO",
|
|
36
|
+
"BUILD_FAIL_ON_ERROR",
|
|
37
|
+
"BUILD_RETRIES"
|
|
38
|
+
];
|
|
39
|
+
env.associate(myVars, myTasks);
|
|
40
|
+
|
|
41
|
+
gulp.task(
|
|
42
|
+
"build",
|
|
43
|
+
"Builds Visual Studio solutions in tree",
|
|
44
|
+
["prebuild"],
|
|
45
|
+
tryBuild
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
gulp.task("quick-build", "Quick build without pre-cursors", tryBuild);
|
|
49
|
+
|
|
50
|
+
async function tryBuild() {
|
|
51
|
+
let attempts = env.resolveNumber("BUILD_RETRIES") + 1;
|
|
52
|
+
if (attempts < 0) {
|
|
53
|
+
attempts = 1;
|
|
54
|
+
}
|
|
55
|
+
const originalAttempts = attempts;
|
|
56
|
+
|
|
57
|
+
while (attempts-- > 0) {
|
|
58
|
+
try {
|
|
59
|
+
await build();
|
|
60
|
+
} catch (e) {
|
|
61
|
+
if (attempts > 0) {
|
|
62
|
+
console.error(chalk.red(`Build fails: ${e}`));
|
|
63
|
+
console.log(`Retrying (${originalAttempts - attempts} / ${originalAttempts})`);
|
|
64
|
+
} else {
|
|
65
|
+
throw e;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function build() {
|
|
72
|
+
const slnMasks = resolveMasks("BUILD_INCLUDE", ["BUILD_EXCLUDE", "BUILD_ADDITIONAL_EXCLUDE"]);
|
|
73
|
+
debug({
|
|
74
|
+
slnMasks,
|
|
75
|
+
cwd: process.cwd()
|
|
76
|
+
});
|
|
77
|
+
const solutions = gulp
|
|
78
|
+
.src(slnMasks, { allowEmpty: true })
|
|
79
|
+
.pipe(throwIfNoFiles(`No solutions found matching masks: ${ slnMasks }}`));
|
|
80
|
+
|
|
81
|
+
// TODO: find a reliable, quick way to determine if the projects to be compiled
|
|
82
|
+
// are all dotnet core -- trawling *.csproj is slow and has caused hangups
|
|
83
|
+
// here, so for now, DNC build must be requested via env DONET_CORE
|
|
84
|
+
return env.resolveFlag("DOTNET_CORE")
|
|
85
|
+
? buildForNetCore(solutions)
|
|
86
|
+
: buildForNETFramework(solutions);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function buildForNetCore(solutions) {
|
|
90
|
+
log.info(gutil.colors.yellow("Building with dotnet core"));
|
|
91
|
+
const
|
|
92
|
+
configuration = env.resolve("BUILD_CONFIGURATION"),
|
|
93
|
+
msbuildArgs = [];
|
|
94
|
+
if (!env.resolveFlag("BUILD_MSBUILD_NODE_REUSE")) {
|
|
95
|
+
msbuildArgs.push("/nodeReuse:false")
|
|
96
|
+
}
|
|
97
|
+
return promisifyStream(
|
|
98
|
+
solutions
|
|
99
|
+
.pipe(
|
|
100
|
+
dotnetClean({
|
|
101
|
+
configuration
|
|
102
|
+
})
|
|
103
|
+
)
|
|
104
|
+
.pipe(
|
|
105
|
+
dotnetBuild({
|
|
106
|
+
verbosity: env.resolve("BUILD_VERBOSITY"),
|
|
107
|
+
configuration,
|
|
108
|
+
// msbuild attempts to re-use nodes, which causes issues
|
|
109
|
+
// if you're building unrelated projects on the same machine with,
|
|
110
|
+
// eg, different versions of Microsoft.Net.Compilers
|
|
111
|
+
msbuildArgs,
|
|
112
|
+
echo: true
|
|
113
|
+
})
|
|
114
|
+
)
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function buildForNETFramework(solutions) {
|
|
119
|
+
log.info(chalk.yellowBright("Building with MsBuild"));
|
|
120
|
+
return promisifyStream(buildAsStream(solutions));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function buildAsStream(solutions) {
|
|
124
|
+
const builder = os.platform() === "win32" ? msbuild : xbuild;
|
|
125
|
+
const config = {
|
|
126
|
+
toolsVersion: env.resolve("BUILD_TOOLSVERSION"),
|
|
127
|
+
targets: env.resolveArray("BUILD_TARGETS"),
|
|
128
|
+
configuration: env.resolve("BUILD_CONFIGURATION"),
|
|
129
|
+
stdout: true,
|
|
130
|
+
verbosity: env.resolve("BUILD_VERBOSITY"),
|
|
131
|
+
errorOnFail: env.resolveFlag("BUILD_FAIL_ON_ERROR"),
|
|
132
|
+
solutionPlatform: env.resolve("BUILD_PLATFORM"),
|
|
133
|
+
// NB: this is the MSBUILD architecture, NOT your desired output architecture
|
|
134
|
+
architecture: env.resolve("BUILD_ARCHITECTURE"),
|
|
135
|
+
nologo: false,
|
|
136
|
+
logCommand: true,
|
|
137
|
+
nodeReuse: env.resolveFlag("BUILD_MSBUILD_NODE_REUSE"),
|
|
138
|
+
maxcpucount: env.resolveNumber("BUILD_MAX_CPU_COUNT")
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
if (env.resolveFlag("BUILD_SHOW_INFO")) {
|
|
142
|
+
logConfig(config, {
|
|
143
|
+
toolsVersion: "Tools version",
|
|
144
|
+
targets: "Build targets",
|
|
145
|
+
configuration: "Build configuration",
|
|
146
|
+
stdout: "Log to stdout",
|
|
147
|
+
verbosity: "Build verbosity",
|
|
148
|
+
errorOnFail: "Any error fails the build",
|
|
149
|
+
solutionPlatform: "Build platform",
|
|
150
|
+
architecture: "Build architecture",
|
|
151
|
+
nodeReuse: "Re-use MSBUILD nodes",
|
|
152
|
+
maxcpucount: "Max CPUs to use for build",
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return solutions
|
|
156
|
+
.pipe(builder(config));
|
|
157
|
+
}
|