Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there anyway to bind gulp tasks to Visual Studio 2017 build buttons?

I have a typescript project in visual studio 2017 that has a gulpfile.js in it. I Want to run my tasks when i click on run, build or clean buttons. Is there anyway to do this?

I know i can do this by set tasks for before or after build, but i want to replace it, and add a task for run button.

Tasks Build Run

like image 685
ptc Avatar asked Jan 19 '18 10:01

ptc


People also ask

How do I add Gulp to Visual Studio?

Now you need to configure Visual Studio Code to use Gulp as a task runner. Press CMD-SHIFT-P to bring up the command palette. Type in "Configure Task Runner", or "CTR" for short, to get to the "Configure Task Runner" option. Select it and choose "Gulp" as the task runner.

How do I get a task runner in Visual Studio?

If you have never used or opened the built in task runner it is simple, press Alt + Shift + Backspace or select it from the other windows list from the View menu. You should see the task runner window at the bottom of Visual Studio.


1 Answers

A little bit later to answer this question, yet here is the summary of the answer combining comments on the original question and my experience so far

Visual Studio does contain Task runner, however, it does not recognize build in tasks defined in gulpfile.js.

In order to get this True integration with Visual Studio, we need to provide additional markup in the gulpfile.js by adding comment, that will populate task runner.

The one line we need is as follows:

/// <binding BeforeBuild='js,css' AfterBuild='move' Clean='cleanup' ProjectOpened='default' />

After adding the file your gulpgile.js should look like this:

/// <binding BeforeBuild='js,css' AfterBuild='move' Clean='cleanup' ProjectOpened='default' />

// Include gulp
var gulp = require('gulp');

If you add another line with additional definitions, it will not be recognized and only the top one is going to be used.

If you are a visual person you might want to to the Visual Studio. Nice guide for setting it up is populated here:

http://www.codedigest.com/quick-start/14/using-of-gulp-gulpfilejs-in-visual-studio-2017

UPDATED based on comments: How to run this the task runner

How to open the task runner window

After you can click on the task in question and it will execute.

if you have added the binding described above, it will be automatically bound to your bound actions.

IE:

for triggering compile, just build the solution.

like image 61
cpoDesign Avatar answered Jan 01 '23 09:01

cpoDesign