Visual Studio 2015 ASP.NET 5, Gulp task not copyin

2019-02-04 15:22发布

I am attempting to alter a task runner script that I borrowed from here, however; after the task runner successfully executes in Visual Studio 2015's Task Runner Explorer -- the files are not actually copied.

Here is the altered script:

/// <binding BeforeBuild='copy-assets' />
"use strict";

var _    = require('lodash'),
    gulp = require('gulp');

gulp.task('copy-assets', function() {
    var assets = {
        js: [
            './node_modules/bootstrap/dist/js/bootstrap.js',
            './node_modules/systemjs/dist/system.src.js',
            './node_modules/angular2/bundles/angular2.dev.js',
            './node_modules/angular2/bundles/router.dev.js',
            './node_modules/angular2/bundles/angular2-polyfills.js',
            './node_modules/angular2/bundles/http.dev.js',
            './node_modules/rxjs/bundles/Rx.js',
            './node_modules/typescript/lib/typescript.js'
        ],
        css: ['./node_modules/bootstrap/dist/css/bootstrap.css']
    };
    _(assets).forEach(function(assets, type) {
        gulp.src(assets).pipe(gulp.dest('./webroot/' + type));
    });
});

The task runner seems to run without error in Visual Studio 2015 Enterprise, but there are no files in my wwwroot/js or wwwroot/css afterwards?

enter image description here

Here is the file structure:

enter image description here

What am I doing wrong and how do I fix this? Any and all help is much appreciated!

1条回答
Explosion°爆炸
2楼-- · 2019-02-04 16:18

Minor oversight... unfortunately gulp silently creates the directory webroot and copies the files into it, it should be wwwroot. Oops!!

/// <binding BeforeBuild='copy-assets' />
"use strict";

var _    = require('lodash'),
    gulp = require('gulp');

gulp.task('copy-assets', function() {
    var assets = {
        js: [
            './node_modules/bootstrap/dist/js/bootstrap.js',
            './node_modules/systemjs/dist/system.src.js',
            './node_modules/angular2/bundles/angular2.dev.js',
            './node_modules/angular2/bundles/router.dev.js',
            './node_modules/angular2/bundles/angular2-polyfills.js',
            './node_modules/angular2/bundles/http.dev.js',
            './node_modules/rxjs/bundles/Rx.js',
            './node_modules/typescript/lib/typescript.js'
        ],
        css: ['./node_modules/bootstrap/dist/css/bootstrap.css']
    };
    _(assets).forEach(function(assets, type) {
        gulp.src(assets).pipe(gulp.dest('./wwwroot/' + type));
    });
});

:punch:

查看更多
登录 后发表回答