Gulpfile 不将文件从源移动到目标
Gulpfile not moving files from source to destination
我在 Visual Studio 2015 项目中创建了一个 gulpfile.js
。它已设置为afterbuild。当我编译我的项目时,我在 Task Runner Explorer 中看到以下消息。下面是gulp文件
的源代码
任务运行器中的错误信息
cmd.exe /c gulp -b "C:\Tom\Personal\PracticeProjects\Angular2\AspNet5Angular2Demo\src\AspNet5Angular2Demo" --color --gulpfile "C:\Tom\Personal\PracticeProjects\Angular2\AspNet5Angular2Demo\src\AspNet5Angular2Demo\Gulpfile.js" default
[12:06:26]
Process terminated with code 1
Gulp 文件
var gulp = require('gulp');
gulp.task('moveToLibs', function (done) {
gulp.src([
'node_modules/angular2/bundles/js',
'node_modules/angular2/bundles/angular2.*.js*',
'node_modules/angular2/bundles/angular2-polyfills.js',
'node_modules/angular2/bundles/http.*.js*',
'node_modules/angular2/bundles/router.*.js*',
'node_modules/es6-shim/es6-shim.min.js*',
'node_modules/angular2/es6/dev/src/testing/shims_for_IE.js',
'node_modules/systemjs/dist/*.*',
'node_modules/jquery/dist/jquery.*js',
'node_modules/bootstrap/dist/js/bootstrap*.js',
'node_modules/rxjs/bundles/Rx.js'
]).pipe(gulp.dest('./wwwroot/libs/'));
gulp.src([
'node_modules/bootstrap/dist/css/bootstrap.css'
]).pipe(gulp.dest('./wwwroot/libs/css'));
});
我修改了上面的代码如下,还是报同样的错误。我已经安装了 merge2
并且在我的 package.json
文件的 devDependencies
下也提到了。
package.json
{
"version": "0.0.0",
"name": "Angular2AspNetCoreDemo",
"dependencies": {
"angular2": "2.0.0-beta.17",
"systemjs": "0.19.27",
"es6-promise": "^3.1.2",
"es6-shim": "^0.35.0",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.6",
"zone.js": "0.6.12",
"bootstrap": "^3.3.6",
"jquery": "^2.2.3"
},
"devDependencies": {
"gulp": "^3.9.1",
"merge2": "1.0.2"
}
}
gulpfile.js
/// <binding AfterBuild='default' />
var gulp = require('gulp');
var merge2 = require('merge2');
gulp.task('moveToLibs', function (done) {
return merge2
(
gulp.src([
'node_modules/angular2/bundles/js',
'node_modules/angular2/bundles/angular2.*.js*',
'node_modules/angular2/bundles/angular2-polyfills.js',
'node_modules/angular2/bundles/http.*.js*',
'node_modules/angular2/bundles/router.*.js*',
'node_modules/es6-shim/es6-shim.min.js*',
'node_modules/angular2/es6/dev/src/testing/shims_for_IE.js',
'node_modules/systemjs/dist/*.*',
'node_modules/jquery/dist/jquery.*js',
'node_modules/bootstrap/dist/js/bootstrap*.js',
'node_modules/rxjs/bundles/Rx.js'
]).pipe(gulp.dest('./wwwroot/libs/')),
gulp.src([
'node_modules/bootstrap/dist/css/bootstrap.css'
]).pipe(gulp.dest('./wwwroot/libs/css')))
});
我也试过在我的 gulp 文件中将其作为两个单独的任务,但仍然出现相同的错误
/// <binding AfterBuild='default' />
var gulp = require('gulp');
gulp.task('moveToLibs', function (done) {
gulp.src([
'node_modules/angular2/bundles/js',
'node_modules/angular2/bundles/angular2.*.js*',
'node_modules/angular2/bundles/angular2-polyfills.js',
'node_modules/angular2/bundles/http.*.js*',
'node_modules/angular2/bundles/router.*.js*',
'node_modules/es6-shim/es6-shim.min.js*',
'node_modules/angular2/es6/dev/src/testing/shims_for_IE.js',
'node_modules/systemjs/dist/*.*',
'node_modules/jquery/dist/jquery.*js',
'node_modules/bootstrap/dist/js/bootstrap*.js',
'node_modules/rxjs/bundles/Rx.js'
]).pipe(gulp.dest('./wwwroot/libs/'))
});
gulp.task('moveToLibsCss', function (done) {
gulp.src([
'node_modules/bootstrap/dist/css/bootstrap.css'
]).pipe(gulp.dest('./wwwroot/libs/css'))
});
我认为您需要将任务名称更改为 default
like
gulp.task('moveToLibs', function (done) {...}
或添加一个空的默认任务并使其取决于您的 moveToLibs
,例如:
gulp.task('default',['moveToLibs']);
我认为不正确的 glob 模式可能是问题的一部分,您有:
gulp.task('moveToLibs', function (done) {
gulp.src([
'node_modules/angular2/bundles/js',
'node_modules/angular2/bundles/angular2.*.js*',
'node_modules/angular2/bundles/angular2-polyfills.js',
'node_modules/angular2/bundles/http.*.js*',
'node_modules/angular2/bundles/router.*.js*',
'node_modules/es6-shim/es6-shim.min.js*',
'node_modules/angular2/es6/dev/src/testing/shims_for_IE.js',
'node_modules/systemjs/dist/*.*',
'node_modules/jquery/dist/jquery.*js',
'node_modules/bootstrap/dist/js/bootstrap*.js',
'node_modules/rxjs/bundles/Rx.js'
]).pipe(gulp.dest('./wwwroot/libs/'))
});
试试这个:
gulp.task('moveToLibs', function (done) {
gulp.src([
// 'node_modules/angular2/bundles/js', // folder doesn't exist
'node_modules/angular2/bundles/angular2.*.js',
'node_modules/angular2/bundles/angular2-polyfills.js',
'node_modules/angular2/bundles/http.*.js',
'node_modules/angular2/bundles/router.*.js',
'node_modules/es6-shim/es6-shim.min.js',
'node_modules/angular2/es6/dev/src/testing/shims_for_IE.js',
'node_modules/systemjs/dist/*.*',
'node_modules/jquery/dist/jquery.js',
'node_modules/bootstrap/dist/js/bootstrap.js',
'node_modules/rxjs/bundles/Rx.js'
]).pipe(gulp.dest('./wwwroot/libs/'))
});
注意差异,它们很小,但很可能是问题的原因。看一下 my post 关于使用 Angular2 和 ASP.NET Core,我详细介绍了一个示例 gulp 文件来自 node_modules
.
更新
在 gulp-debug
上添加 devDependency
并添加:
var debug = require("gulp-debug");
然后将其添加到您的流中以调试文件以确保您获得预期的结果:
gulp.task('moveToLibs', function (done) {
gulp.src([
// 'node_modules/angular2/bundles/js', // folder doesn't exist
'node_modules/angular2/bundles/angular2.*.js',
'node_modules/angular2/bundles/angular2-polyfills.js',
'node_modules/angular2/bundles/http.*.js',
'node_modules/angular2/bundles/router.*.js',
'node_modules/es6-shim/es6-shim.min.js',
'node_modules/angular2/es6/dev/src/testing/shims_for_IE.js',
'node_modules/systemjs/dist/*.*',
'node_modules/jquery/dist/jquery.js',
'node_modules/bootstrap/dist/js/bootstrap.js',
'node_modules/rxjs/bundles/Rx.js'
])
.pipe(debug())
.pipe(gulp.dest('./wwwroot/libs/'))
});
我在 Visual Studio 2015 项目中创建了一个 gulpfile.js
。它已设置为afterbuild。当我编译我的项目时,我在 Task Runner Explorer 中看到以下消息。下面是gulp文件
任务运行器中的错误信息
cmd.exe /c gulp -b "C:\Tom\Personal\PracticeProjects\Angular2\AspNet5Angular2Demo\src\AspNet5Angular2Demo" --color --gulpfile "C:\Tom\Personal\PracticeProjects\Angular2\AspNet5Angular2Demo\src\AspNet5Angular2Demo\Gulpfile.js" default
[12:06:26]
Process terminated with code 1
Gulp 文件
var gulp = require('gulp');
gulp.task('moveToLibs', function (done) {
gulp.src([
'node_modules/angular2/bundles/js',
'node_modules/angular2/bundles/angular2.*.js*',
'node_modules/angular2/bundles/angular2-polyfills.js',
'node_modules/angular2/bundles/http.*.js*',
'node_modules/angular2/bundles/router.*.js*',
'node_modules/es6-shim/es6-shim.min.js*',
'node_modules/angular2/es6/dev/src/testing/shims_for_IE.js',
'node_modules/systemjs/dist/*.*',
'node_modules/jquery/dist/jquery.*js',
'node_modules/bootstrap/dist/js/bootstrap*.js',
'node_modules/rxjs/bundles/Rx.js'
]).pipe(gulp.dest('./wwwroot/libs/'));
gulp.src([
'node_modules/bootstrap/dist/css/bootstrap.css'
]).pipe(gulp.dest('./wwwroot/libs/css'));
});
我修改了上面的代码如下,还是报同样的错误。我已经安装了 merge2
并且在我的 package.json
文件的 devDependencies
下也提到了。
package.json
{
"version": "0.0.0",
"name": "Angular2AspNetCoreDemo",
"dependencies": {
"angular2": "2.0.0-beta.17",
"systemjs": "0.19.27",
"es6-promise": "^3.1.2",
"es6-shim": "^0.35.0",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.6",
"zone.js": "0.6.12",
"bootstrap": "^3.3.6",
"jquery": "^2.2.3"
},
"devDependencies": {
"gulp": "^3.9.1",
"merge2": "1.0.2"
}
}
gulpfile.js
/// <binding AfterBuild='default' />
var gulp = require('gulp');
var merge2 = require('merge2');
gulp.task('moveToLibs', function (done) {
return merge2
(
gulp.src([
'node_modules/angular2/bundles/js',
'node_modules/angular2/bundles/angular2.*.js*',
'node_modules/angular2/bundles/angular2-polyfills.js',
'node_modules/angular2/bundles/http.*.js*',
'node_modules/angular2/bundles/router.*.js*',
'node_modules/es6-shim/es6-shim.min.js*',
'node_modules/angular2/es6/dev/src/testing/shims_for_IE.js',
'node_modules/systemjs/dist/*.*',
'node_modules/jquery/dist/jquery.*js',
'node_modules/bootstrap/dist/js/bootstrap*.js',
'node_modules/rxjs/bundles/Rx.js'
]).pipe(gulp.dest('./wwwroot/libs/')),
gulp.src([
'node_modules/bootstrap/dist/css/bootstrap.css'
]).pipe(gulp.dest('./wwwroot/libs/css')))
});
我也试过在我的 gulp 文件中将其作为两个单独的任务,但仍然出现相同的错误
/// <binding AfterBuild='default' />
var gulp = require('gulp');
gulp.task('moveToLibs', function (done) {
gulp.src([
'node_modules/angular2/bundles/js',
'node_modules/angular2/bundles/angular2.*.js*',
'node_modules/angular2/bundles/angular2-polyfills.js',
'node_modules/angular2/bundles/http.*.js*',
'node_modules/angular2/bundles/router.*.js*',
'node_modules/es6-shim/es6-shim.min.js*',
'node_modules/angular2/es6/dev/src/testing/shims_for_IE.js',
'node_modules/systemjs/dist/*.*',
'node_modules/jquery/dist/jquery.*js',
'node_modules/bootstrap/dist/js/bootstrap*.js',
'node_modules/rxjs/bundles/Rx.js'
]).pipe(gulp.dest('./wwwroot/libs/'))
});
gulp.task('moveToLibsCss', function (done) {
gulp.src([
'node_modules/bootstrap/dist/css/bootstrap.css'
]).pipe(gulp.dest('./wwwroot/libs/css'))
});
我认为您需要将任务名称更改为 default
like
gulp.task('moveToLibs', function (done) {...}
或添加一个空的默认任务并使其取决于您的 moveToLibs
,例如:
gulp.task('default',['moveToLibs']);
我认为不正确的 glob 模式可能是问题的一部分,您有:
gulp.task('moveToLibs', function (done) {
gulp.src([
'node_modules/angular2/bundles/js',
'node_modules/angular2/bundles/angular2.*.js*',
'node_modules/angular2/bundles/angular2-polyfills.js',
'node_modules/angular2/bundles/http.*.js*',
'node_modules/angular2/bundles/router.*.js*',
'node_modules/es6-shim/es6-shim.min.js*',
'node_modules/angular2/es6/dev/src/testing/shims_for_IE.js',
'node_modules/systemjs/dist/*.*',
'node_modules/jquery/dist/jquery.*js',
'node_modules/bootstrap/dist/js/bootstrap*.js',
'node_modules/rxjs/bundles/Rx.js'
]).pipe(gulp.dest('./wwwroot/libs/'))
});
试试这个:
gulp.task('moveToLibs', function (done) {
gulp.src([
// 'node_modules/angular2/bundles/js', // folder doesn't exist
'node_modules/angular2/bundles/angular2.*.js',
'node_modules/angular2/bundles/angular2-polyfills.js',
'node_modules/angular2/bundles/http.*.js',
'node_modules/angular2/bundles/router.*.js',
'node_modules/es6-shim/es6-shim.min.js',
'node_modules/angular2/es6/dev/src/testing/shims_for_IE.js',
'node_modules/systemjs/dist/*.*',
'node_modules/jquery/dist/jquery.js',
'node_modules/bootstrap/dist/js/bootstrap.js',
'node_modules/rxjs/bundles/Rx.js'
]).pipe(gulp.dest('./wwwroot/libs/'))
});
注意差异,它们很小,但很可能是问题的原因。看一下 my post 关于使用 Angular2 和 ASP.NET Core,我详细介绍了一个示例 gulp 文件来自 node_modules
.
更新
在 gulp-debug
上添加 devDependency
并添加:
var debug = require("gulp-debug");
然后将其添加到您的流中以调试文件以确保您获得预期的结果:
gulp.task('moveToLibs', function (done) {
gulp.src([
// 'node_modules/angular2/bundles/js', // folder doesn't exist
'node_modules/angular2/bundles/angular2.*.js',
'node_modules/angular2/bundles/angular2-polyfills.js',
'node_modules/angular2/bundles/http.*.js',
'node_modules/angular2/bundles/router.*.js',
'node_modules/es6-shim/es6-shim.min.js',
'node_modules/angular2/es6/dev/src/testing/shims_for_IE.js',
'node_modules/systemjs/dist/*.*',
'node_modules/jquery/dist/jquery.js',
'node_modules/bootstrap/dist/js/bootstrap.js',
'node_modules/rxjs/bundles/Rx.js'
])
.pipe(debug())
.pipe(gulp.dest('./wwwroot/libs/'))
});