VS2017 Task Runner Explorer No Tasks Found

倾然丶 夕夏残阳落幕 提交于 2019-12-23 07:37:00

问题


I'm trying to set up gulp in an MVC Core project within VS 2017. I have what I believe to be a valid gulpfile.js:

var gulp = require('gulp');
var rimraf = require('rimraf');
var concat = require('gulp-concat');
var cssmin = require('gulp-cssmin');
var uglify = require( 'gulp-uglify' );

var paths = {
    webroot: './wwwroot/',
};

paths.js = paths.webroot + 'js/**/*.js';
paths.minJs = paths.webroot + 'js/**/*.min.js';
paths.css = paths.webroot + 'css/**/*.css';
paths.minCss = paths.webroot + 'css/**/*.min.css';
paths.concatJsDest = paths.webroot + "js/site.min.js";
paths.concatCssDest = paths.webroot + "css/site.min.css";

gulp.task("clean:js", function (cb) {
    rimraf(paths.concatJsDest, cb);
});

gulp.task("clean:css", function (cb) {
    rimraf(paths.concatCssDest, cb);
});

gulp.task( "clean", ["clean:js", "clean:css"] );

But when I open Task Runner Explorer I get the message "(no tasks found)".

I've checked to ensure all the gulp packages were installed via npm. I also added a package.json file. But the tasks are still not being found.

What am I doing wrong?


回答1:


Apparently you have to install gulp locally within your project for it to work properly with Visual Studio. Global install won't work. Deleting the global copy and installing it locally solved the problem.




回答2:


I was faced the same issue, and fix this after running two commands. Please refer below the process:

1) Right click on your gulp file in visual-studio, and choose "Open Command Line > PowerShell"

2) Run the command npm install gulp for install gulp. (You have to install gulp in your project, no matter if you have already installed gulp globally, but in this case you have to install the gulp in your project)

and press enter.

3) After execution of command go to task runner explorer in Visual-Studio and press the refresh button.

After pressing the refresh button you will see all your task list under task runner.

If you found any error related to "missing module" in output window like below:

Then you have to install missing npm plugins, for this just run the below command (into powershell): npm install and press enter. This command will install all the missing plugin, refer below image:

And then press again the refresh button in task runner explorer and you will see all your gulp task list under task runner window.

Hope this solution will help.



来源:https://stackoverflow.com/questions/43245801/vs2017-task-runner-explorer-no-tasks-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!