问题
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.
- Installed the dnx-watch command:
dnu commands install Microsoft.Dnx.Watcher
- Added gulp-shell to package.json under 'devDependencies'
- Added
var shell = require('gulp-shell');
to gulpfile.js - Added
gulp.task('watch', shell.task(['dnx-watch web']));
to gulpfile.js - 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