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

丶灬走出姿态 提交于 2019-12-11 12:32:20

问题


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"


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/34612062/how-to-make-kestrel-update-on-the-fly-with-visual-studio

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