Visual studio 2015 Gulpfile未将文件从源移动到目标

Visual studio 2015 Gulpfile未将文件从源移动到目标,visual-studio-2015,angular,gulp,task-runner-explorer,Visual Studio 2015,Angular,Gulp,Task Runner Explorer,我在Visual Studio 2015中创建了一个gulpfile.js。它已被设置为后建。当我编译我的项目时,我在我的TaskRunner资源管理器中看到以下消息。下面是gulp文件的源代码 任务运行程序中的错误消息 cmd.exe /c gulp -b "C:\Tom\Personal\PracticeProjects\Angular2\AspNet5Angular2Demo\src\AspNet5Angular2Demo" --color --gulpfile "C:\Tom\Perso

我在Visual Studio 2015中创建了一个
gulpfile.js
。它已被设置为后建。当我编译我的项目时,我在我的TaskRunner资源管理器中看到以下消息。下面是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
咽锉

   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
文件的
devdependences
下也提到了

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')))

    });
//
var gulp=需要(“gulp”);
var merge2=require('merge2');
吞咽任务('moveToLibs',函数(完成){
返回合并2
(
大口([
'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/fimmers_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(大口目的地('./wwwroot/libs/'),
大口([
'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'))

});
//
var gulp=需要(“gulp”);
吞咽任务('moveToLibs',函数(完成){
大口([
'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/fimmers_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/'))
});
吞咽任务('moveToLibsCss',函数(完成){
大口([
'node_modules/bootstrap/dist/css/bootstrap.css'
]).pipe(gulp.dest('./wwwroot/libs/css'))
});

我认为您需要将任务名称更改为
默认值

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/'))
});
请注意这些差异,它们很小,但它们很可能是问题的原因。看一看如何将Angular2ASP.NET核心一起使用,我详细介绍了一个从
节点模块中提取的示例gulp文件

更新

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/'))
});

你不能像那样使用2个src,使用merge stream或merge2,或者让它成为2个任务,或者如果你需要串行的话使用run sequence,或者使用gulp4的serials或parallel。另外,对那些gulp.src或async不会被作为两个单独的任务尝试,但仍然是相同的错误使用return gulp.src
不仅仅是
gulp.src
,这是巨大的区别。尝试过获得与文章中提到的相同的错误above@Tom好吧您的gulp文件名是否为
Gulpfile.js
并带有大写字母?@Tom这可能是问题所在。因为您问题的错误消息中有一个大写字母的
Gulpfile.js
,所以将文件改为大写,但仍然没有work@Tom还是同样的错误吗?错误消息中的路径是否正确?因为我认为gulp根本无法读取文件,所以我很不幸地得到了同样的错误。非常令人沮丧的消息。成功了。谢谢大卫,我看过你的博客了。我刚刚将其添加到最后一行gulp.task('default',['moveToLibs','movetolibscs']);太棒了,谢谢——我很感谢你的投票并接受