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.
@@ -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
- env.associate(myVars, myTasks);
39
-
40
- gulp.task(
41
- "build",
42
- "Builds Visual Studio solutions in tree",
43
- ["prebuild"],
44
- build
45
- );
46
-
47
- gulp.task("quick-build", "Quick build without pre-cursors", build);
48
-
49
- async function build() {
50
- const slnMasks = resolveMasks("BUILD_INCLUDE", [ "BUILD_EXCLUDE", "BUILD_ADDITIONAL_EXCLUDE"]);
51
- debug({
52
- slnMasks,
53
- cwd: process.cwd()
54
- });
55
- const solutions = gulp
56
- .src(slnMasks, { allowEmpty: true })
57
- .pipe(throwIfNoFiles(`No solutions found matching masks: ${slnMasks}}`));
58
-
59
- // TODO: find a reliable, quick way to determine if the projects to be compiled
60
- // are all dotnet core -- trawling *.csproj is slow and has caused hangups
61
- // here, so for now, DNC build must be requested via env DONET_CORE
62
- return env.resolveFlag("DOTNET_CORE")
63
- ? buildForNetCore(solutions)
64
- : buildForNETFramework(solutions);
65
- }
66
-
67
- function buildForNetCore(solutions) {
68
- log.info(gutil.colors.yellow("Building with dotnet core"));
69
- const
70
- configuration = env.resolve("BUILD_CONFIGURATION"),
71
- msbuildArgs = [];
72
- if (!env.resolveFlag("BUILD_MSBUILD_NODE_REUSE")) {
73
- msbuildArgs.push("/nodeReuse:false")
74
- }
75
- return promisifyStream(
76
- solutions
77
- .pipe(
78
- dotnetClean({
79
- configuration
80
- })
81
- )
82
- .pipe(
83
- dotnetBuild({
84
- verbosity: env.resolve("BUILD_VERBOSITY"),
85
- configuration,
86
- // msbuild attempts to re-use nodes, which causes issues
87
- // if you're building unrelated projects on the same machine with,
88
- // eg, different versions of Microsoft.Net.Compilers
89
- msbuildArgs,
90
- echo: true
91
- })
92
- )
93
- );
94
- }
95
-
96
- function buildForNETFramework(solutions) {
97
- log.info(chalk.yellowBright("Building with MsBuild"));
98
- return promisifyStream(buildAsStream(solutions));
99
- }
100
-
101
- function buildAsStream(solutions) {
102
- const builder = os.platform() === "win32" ? msbuild : xbuild;
103
- const config = {
104
- toolsVersion: env.resolve("BUILD_TOOLSVERSION"),
105
- targets: env.resolveArray("BUILD_TARGETS"),
106
- configuration: env.resolve("BUILD_CONFIGURATION"),
107
- stdout: true,
108
- verbosity: env.resolve("BUILD_VERBOSITY"),
109
- errorOnFail: env.resolveFlag("BUILD_FAIL_ON_ERROR"),
110
- solutionPlatform: env.resolve("BUILD_PLATFORM"),
111
- // NB: this is the MSBUILD architecture, NOT your desired output architecture
112
- architecture: env.resolve("BUILD_ARCHITECTURE"),
113
- nologo: false,
114
- logCommand: true,
115
- nodeReuse: env.resolveFlag("BUILD_MSBUILD_NODE_REUSE"),
116
- maxcpucount: env.resolveNumber("BUILD_MAX_CPU_COUNT")
117
- };
118
-
119
- if (env.resolveFlag("BUILD_SHOW_INFO")) {
120
- logConfig(config, {
121
- toolsVersion: "Tools version",
122
- targets: "Build targets",
123
- configuration: "Build configuration",
124
- stdout: "Log to stdout",
125
- verbosity: "Build verbosity",
126
- errorOnFail: "Any error fails the build",
127
- solutionPlatform: "Build platform",
128
- architecture: "Build architecture",
129
- nodeReuse: "Re-use MSBUILD nodes",
130
- maxcpucount: "Max CPUs to use for build",
131
- });
132
- }
133
- return solutions
134
- .pipe(builder(config));
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
+ }