Ilya Chernomordik
Ilya Chernomordik

Reputation: 30355

How to make Kestrel update on the fly with Visual Studio?

I have this command (default one) in project.json:

"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"

},

Now after I do run Kestrel and change my controller there is no automatic update. As far as I remember it did work in beta-8 automatically (when there was IISExpress). Is there a way to make the same now?

P.S. I also did not find any command apart from Ctrl+C that closes the server that you can run in command line. Maybe there is some hidden one that restarts it?

Update: It seems that we need to run "dnx-watch web", but Visual Studio by default runs "dnx" command. I am not sure how this can be changed (or if it's possible to change "dnx" to "dnx-watch"

Upvotes: 1

Views: 828

Answers (2)

Alex
Alex

Reputation: 546

Here's what I did based on @tugberk's answer.

  1. Installed the dnx-watch command: dnu commands install Microsoft.Dnx.Watcher
  2. Added gulp-shell to package.json under 'devDependencies'
  3. Added var shell = require('gulp-shell'); to gulpfile.js
  4. Added gulp.task('watch', shell.task(['dnx-watch web'])); to gulpfile.js
  5. If you want dnx-watch to run when you open your project, add the 'watch' task as a Project Open binding within the Task Runner Explorer.

Now if you make a change to your code and hit ctrl+s, dnx-watch will restart your app without you needing to explicitly build the project.

Upvotes: 2

tugberk
tugberk

Reputation: 58494

You can use dnx-watch. Here is more info: Integrating Visual Studio Code with dnx-watch to develop ASP.NET 5 applications.

Upvotes: 2

Related Questions