2

In visual studio 2017, in an attempt to add SASS compilation using Gulp to a netcore2 project using this tutorial I ran into trouble with the Task Runner Explorer. On the project I want to add gulp to, the Task Runner does not display any task.

enter image description here

If I try to add a Gulpfile.js to an other netcore 2 project, that it be older or newly created, I can see some tasks from the bundleconfig.json and an empty task list for the Gulpfile.js. enter image description here

On all of these projects I have an identical gulpfile.js which is as follow:

/*
This file is the main entry point for defining Gulp tasks and using Gulp plugins.
Click here to learn more. https://go.microsoft.com/fwlink/?LinkId=518007
*/
var gulp = require('gulp');
var sass = require('gulp-sass');

var paths = {
    webroot: "./wwwroot/",
    sass: "./wwwroot/scss/",
    css: "./wwwroot/css/"
};

gulp.task('scss', function ()
{
    return gulp.src(paths.sass + '/**/*.scss')
        .pipe(sass().on('error', sass.logError))
        .pipe(gulp.dest(paths.webroot + 'css/'));
});

gulp.task('watch', function ()
{
    gulp.watch(paths.sass + '**/*.scss', ["scss"]);
});

I can run the gulp jobs using the PowerShell command line and they properly compile my scss, which means the gulpfile.js is valid.

As per other Stack Overflow questions/answers I tried:

  • installing Gulp both locally and globally, no change src src2.
  • adding an external tool that targets nodejs src external tools
  • adding the npm task runner VS2017 extension
  • adding the Bundler & Minifier VS2017 extension
  • restarting VS2017 a few dozens of time in total, mostly in between each of the above steps/attempts
  • running npm install several times
  • taking the project out of the solution folder in which it was src

Regarding the lines without a src I could not find the thread that said to try this particular fix, but I did try it.

None of the above fixed it. Has anyone run into this problem and fixed it in an other way than the ones described above ? Does anyone know why this happens and what I'm doing wrong ?

Mathieu VIALES
  • 3,852
  • 2
  • 22
  • 44

3 Answers3

2

I managed to get it to work. I do not know exactly which step fixed my problem but I did it all in this order:

  1. Remove gulp both locally and globally
  2. Remove the Bundler & Minifier vs extension
  3. Remove the npm task runner vs extension
  4. Restart VS 2017 (make sure it takes into account the removal of the extensions
  5. Create a new netcore 2.0 app at the root of the solution with an unique name (several of my projects had the same name, in different folders)
  6. Copy/paste all the files from the old project to the new one
  7. Restart VS 2017
  8. Right click on bundleconfig.json --> Bundler & minifier --> Convert to Gulp. This will install gulp and generate a gulpfile.js at the root of the project.
  9. Add the needed Gulp tasks
  10. Right click on the gulpfile.js --> Task runner explorer
  11. DONE
Rafael Herscovici
  • 14,724
  • 15
  • 61
  • 91
Mathieu VIALES
  • 3,852
  • 2
  • 22
  • 44
2

For me the fix was running the Gulp locally.

I tried running it globally but it didn't work.

Stephen Rauch
  • 40,722
  • 30
  • 82
  • 105
Jason
  • 21
  • 1
0

The answer by @mathieu-viales inspired me to do the following which also worked:

  1. Remove the affected project from the solution, save and close.
  2. Reopen the solution, re-add the project to the solution.
  3. Done! The Gulp tasks now appeared in the VS Test Runner explorer.
Oliver
  • 8,258
  • 7
  • 64
  • 94