This repository has been archived by the owner on Sep 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
clean.js
71 lines (71 loc) · 3.05 KB
/
clean.js
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
"use strict";
(function () {
const gulp = requireModule("gulp"), promisifyStream = requireModule("promisify-stream"), tryDo = requireModule("try-do"), debug = requireModule("debug")(__filename), throwIfNoFiles = requireModule("throw-if-no-files"), msbuild = requireModule("gulp-msbuild"), dotnetClean = requireModule("gulp-dotnet-cli").clean, resolveMasks = requireModule("resolve-masks"), env = requireModule("env"), chalk = requireModule("ansi-colors");
const myVars = [
env.BUILD_TOOLSVERSION,
env.BUILD_CONFIGURATION,
env.BUILD_VERBOSITY,
env.BUILD_MAX_CPU_COUNT,
env.BUILD_FAIL_ON_ERROR,
env.BUILD_PLATFORM,
env.BUILD_ARCHITECTURE,
env.BUILD_MSBUILD_NODE_REUSE,
env.BUILD_RETRIES,
env.BUILD_TARGETS,
env.BUILD_FRAMEWORK,
env.BUILD_RUNTIME
];
env.associate(myVars, "clean");
gulp.task("clean", "Invokes the 'Clean' target on all solutions in the tree", tryClean);
function tryClean() {
return tryDo(clean, "BUILD_RETRIES", e => console.error(chalk.red(`Clean fails: ${e}`)));
}
function clean() {
const useDotNetCore = env.resolveFlag("DOTNET_CORE");
if (useDotNetCore) {
return cleanWithDotnet();
}
else {
return cleanWithMsBuild();
}
}
async function cleanWithDotnet() {
const configuration = env.resolveArray("BUILD_CONFIGURATION"), slnMasks = resolveBuildSolutionMasks(), targets = env.resolveArray("BUILD_TARGETS", "BUILD_INCLUDE");
debug({
slnMasks,
targets,
cwd: process.cwd()
});
const solutions = gulp
.src(slnMasks, { allowEmpty: true })
.pipe(throwIfNoFiles(`No solutions found matching masks: ${slnMasks}}`));
await promisifyStream(solutions.pipe(dotnetClean({
target: "(not set)",
configuration,
msbuildProperties: env.resolveMap(env.MSBUILD_PROPERTIES),
verbosity: env.resolve(env.BUILD_VERBOSITY),
framework: env.resolve(env.BUILD_FRAMEWORK),
runtime: env.resolve(env.BUILD_RUNTIME)
})));
}
function resolveBuildSolutionMasks() {
return resolveMasks("BUILD_INCLUDE", ["BUILD_EXCLUDE", "BUILD_ADDITIONAL_EXCLUDE"]);
}
function cleanWithMsBuild() {
const slnMasks = resolveBuildSolutionMasks();
return promisifyStream(gulp.src(slnMasks)
.pipe(msbuild({
toolsVersion: env.resolve("BUILD_TOOLSVERSION"),
targets: ["Clean"],
configuration: env.resolve("BUILD_CONFIGURATION"),
stdout: true,
logCommand: true,
errorOnFail: env.resolveFlag("BUILD_FAIL_ON_ERROR"),
solutionPlatform: env.resolve("BUILD_PLATFORM"),
architecture: env.resolve("BUILD_ARCHITECTURE"),
verbosity: env.resolve("BUILD_VERBOSITY"),
nodeReuse: env.resolveFlag("BUILD_MSBUILD_NODE_REUSE"),
maxcpucount: env.resolveNumber("BUILD_MAX_CPU_COUNT")
})));
}
})();