TResponse
TResponse

Reputation: 4125

Execute Gulp.js tasks post build in VS2015

I have a basic Asp.Net 5 site which used Gulp.JS tasks to clean, copy and minify CSS and JS files.

When running these tasks in the Task Runner Explorer - all is good and the old scripts are removed, new ones copied and files minified.

I wish to automate these tasks in VS2015 - so when I build the project the following will happen:

Now I may be completely off track here but I would have thought that in the project.json file I should be able to call these gulp tasks in the scripts config like so:

"scripts": {
    "prebuild": [ "gulp clean" ],
    "postbuild": ["gulp copy" , "gulp min" ],
    "prepublish": [ "npm install", "bower install"]

}

The clean works perfectly - however the copy and min tasks do not run at all. Any ideas on how I could automate this behaviour please?

Upvotes: 5

Views: 2862

Answers (1)

Marcin Zablocki
Marcin Zablocki

Reputation: 10683

All you have to do is to add binding to build steps in your gulpfile.js (in the first line):

/// <binding Clean='clean' AfterBuild='postbuild' />

After that, you will have your steps in Task Runner Explorer: gulp build in Visual Studio 2015

The scripts section in project.json works only for building outside of Visual Studio, while using dnu command:

dnu build

Upvotes: 7

Related Questions