我正在使用Gulp使用gulp-msbuild构建我的Web项目。但是,我有多个Web项目需要具有不同的构建参数才能发布到正确的文件夹。
这是我的gulpfile.js的一部分:
gulp.task('publish', function () {
var webProjectsPaths = [
'/Project1/Project1.csproj'
'/Project2/Project2.csproj'
];
return gulp
.src(webProjectsPaths)
.pipe(msbuild({
targets: ['WebPublish'],
toolsVersion: 14.0,
errorOnFail: true,
stdout: true,
properties: {
Configuration: 'Debug',
WebPublishMethod: 'FileSystem',
DeleteExistingFiles: true,
PublishUrl: 'Publish/##csproj file name without the extension##'
},
}));
});
我希望在将.src
任务发送到msbuild
任务之前访问每个路径,以便我PublishUrl
动态##csproj file name without the extension##
。(见library(caTools)
library(caret)
data(iris)
Data = iris[,-5]
Label = iris[, 5]
# basic interface
model = LogitBoost(Data, Label, nIter=20)
print(confusionMatrix(predict(model, Data, nIter= 2), Label)$overall[1])
Accuracy
0.971831
)。
答案 0 :(得分:1)
如果将该gulp管道移动到函数中,该函数可以提前确定路径并发布url。
// returns one stream that builds one project
function buildWebProject(projectName) {
var path = '/' + projectName + '/' + projectName + '.csproj';
var publishUrl = 'Publish/' + projectName;
return gulp.src(path)
.pipe(msbuild({
targets: ['WebPublish'],
toolsVersion: 14.0,
errorOnFail: true,
stdout: true,
properties: {
Configuration: 'Debug',
WebPublishMethod: 'FileSystem',
DeleteExistingFiles: true,
PublishUrl: publishUrl
}
}));
}
然后在你的"发布" gulp任务,使用该函数为每个项目创建流,使用merge-stream之类的模块将流组合成单个流,并返回合并的流。
var mergeStream = require('merge-stream');
gulp.task('publish', function () {
var webProjects = [
'Project1',
'Project2'
];
var streams = webProjects.map(buildWebProject);
return mergeStream(streams);
}