-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
96 lines (85 loc) · 3.81 KB
/
gulpfile.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
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
/*jslint node: true */
"use strict";
var gulp = require("gulp");
var nopt = require("nopt");
var path = require("path");
var requireDir = require("require-dir");
var build = require("./build.js");
var config = build.config;
var foreach = require("gulp-foreach");
var msbuild = require("gulp-msbuild");
var args = nopt({
"env": [String, null]
});
build.setEnvironment(args.env);
gulp.task("apply-xml-transform", function () {
var layerPathFilters = [
"./src/Foundation/**/*." + build.AlwaysApplyName + ".config",
"./src/Feature/**/*." + build.AlwaysApplyName + ".config",
"./src/Context/**/*." + build.AlwaysApplyName + ".config",
"./src/Project/**/*." + build.AlwaysApplyName + ".config",
"./src/Foundation/**/*." + build.AlwaysApplyName.toLowerCase() + ".config",
"./src/Feature/**/*." + build.AlwaysApplyName.toLowerCase() + ".config",
"./src/Context/**/*." + build.AlwaysApplyName.toLowerCase() + ".config",
"./src/Project/**/*." + build.AlwaysApplyName.toLowerCase() + ".config",
"./src/Foundation/**/*." + build.config.name + ".config",
"./src/Feature/**/*." + build.config.name + ".config",
"./src/Context/**/*." + build.config.name + ".config",
"./src/Project/**/*." + build.config.name + ".config",
"./src/Foundation/**/*." + build.config.name.toLowerCase() + ".config",
"./src/Feature/**/*." + build.config.name.toLowerCase() + ".config",
"./src/Context/**/*." + build.config.name.toLowerCase() + ".config",
"./src/Project/**/*." + build.config.name.toLowerCase() + ".config",
"!./src/**/obj/**/*.config",
"!./src/**/bin/**/*.config",
"!./src/**/output/**/*.config"];
return gulp.src(layerPathFilters)
.pipe(foreach(function (stream, file) {
var filePathOriginal = file.path;
var filePath = filePathOriginal.toLowerCase();
if (filePath.indexOf("web." + build.config.name.toLowerCase() + ".config") == -1 && filePath.indexOf("web." + build.AlwaysApplyName.toLowerCase() + ".config") == -1) {
var isapp_config = filePath.indexOf("app_config") > 0;
if (isapp_config) {
var fileToTransform = filePath.slice(filePath.indexOf("app_config"));
}
var issecurityProvider = filePath.indexOf("securityprovider") > 0;
if (issecurityProvider) {
var fileToTransform = filePath.slice(filePath.indexOf("securityprovider"));
}
if (filePath.indexOf(build.config.name.toLowerCase()) != -1) {
var fileToTransform = fileToTransform.replace("." + build.config.name.toLowerCase(), "");
}
else {
var fileToTransform = fileToTransform.replace("." + build.AlwaysApplyName.toLowerCase(), "");
}
}
else {
var fileToTransform = "web.config";
}
var dest = build.config.websiteRoot;
if (!path.isAbsolute(dest)) {
dest = path.join(process.cwd(), dest);
}
console.log("Applying configuration transform: " + filePathOriginal);
console.log("To destination file: " + dest + "\\" + fileToTransform)
return gulp.src("./node_modules/@pentia/configuration-transformer/applytransform.targets")
.pipe(msbuild({
targets: ["ApplyTransform"],
configuration: build.config.name,
logCommand: false,
stderr: build.solutionConfiguration.msbuild.showError,
stdout: build.solutionConfiguration.msbuild.showStandardOutput,
verbosity: build.solutionConfiguration.msbuild.verbosity,
maxcpucount: 0,
toolsVersion: build.solutionConfiguration.msbuild.toolsversion,
properties: {
WebConfigToTransform: dest,
TransformFile: filePathOriginal,
FileToTransform: fileToTransform
}
}));
}));
});
gulp.task("default", function () {
console.log("You need to specifiy a task.");
});