简体   繁体   中英

How can I run a gulp task after IIS Express session starts in visual studio 2015

I want to run a gulp task that MUST start after my http server is online on port 55555.

Thus I manually start my IIS Express debugging via F5 in Visual Studion then I start my 'watch' task runner.

I would like to have this in One step automated.

I am using VS 2015 Pro with asp.net core/vnext project.

gulp.task('watch', function () {

bs.init({
  proxy: 'localhost:55555',
    notify: true,
    open: true,
    logLevel: 'debug',

});

bs.watch("./wwwroot/app/**/*.js", function (event, file) {
    gutil.log('Event: ' + event);
    if (event === "change") {
        bs.reload();
    }
});

});

Hooking the watch task in the after-build event of the task runner does not help because the iis express is started as last when the build is done and the watch task is run :/

One solution could be running my app locally on Full IIS thus port 55555 is always online, but the iis express is handy for development ;-)

Visual Studio have built in solution to run grunt gulp using binding event

As you can see we have Before build, After Build, Clean, Project Open

在此输入图像描述

Example I have Gruntfile.js and it will run after the build of mine solution

/// <binding AfterBuild='cleanup' />
module.exports = function(grunt) {
  require("jit-grunt")(grunt);
  grunt.initConfig({
    clean: ["./Modules/*"],
    copy: {
      main: {
        expand: true,
        src: [
          "../Modules/**/Views/**",
          "../Modules/**/bin/Debug/**/**/*.*",
          "../Modules/**/wwwroot/**",
          "!../Modules/AwesomeCMSCore.Modules.Frontend/**"
        ],
        dest: "./Modules/"
      },
      css: {
        expand: true,
        cwd: "../Modules/AwesomeCMSCore.Modules.Frontend/wwwroot/dist",
        src: ["cmscore.css"],
        dest: "./wwwroot/dist/"
      },
      js: {
        expand: true,
        cwd: "../Modules/AwesomeCMSCore.Modules.Frontend/wwwroot/dist",
        src: ["*.js"],
        dest: "./wwwroot/dist/"
      },
      static: {
        expand: true,
        cwd: "../Modules/AwesomeCMSCore.Modules.Frontend/wwwroot/dist",
        src: ["**"],
        dest: "./wwwroot/dist/"
      }
    },
    watch: {
      css: {
        files: ["../Modules/**/wwwroot/dist/*.css"],
        tasks: ["copy:css"],
        options: {
          reload: true,
          spawn: false
        }
      },
      js: {
        files: ["../Modules/**/wwwroot/dist/*.js"],
        tasks: ["copy:js"],
        options: {
          reload: true,
          spawn: false
        }
      }
    }
  });
  grunt.registerTask("default", ["watch"]);
  grunt.registerTask("cleanup", [
    "clean",
    "copy:main",
    "copy:static"
  ]);
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM