Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • Old scripts are removed using the clean taks
  • New scripts are copied over - using the copy task
  • CSS and JS are minified using a min taks (will minify CSS and JS by way of calling separate minify tasks for each. (Prod and staging use minified versions and dev uses the normal js and css files).

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?

like image 587
TResponse Avatar asked Sep 09 '15 00:09

TResponse


1 Answers

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
like image 65
Marcin Zablocki Avatar answered Oct 30 '22 16:10

Marcin Zablocki