问题描述
我在project.json中有以下命令(默认命令):
I have this command (default one) in project.json:
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
现在,在我运行Kestrel并更改控制器后,没有自动更新.据我所知,它确实可以在beta-8中自动运行(有IISExpress时).现在有办法做到吗?
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.除了Ctrl + C以外,我也没有找到任何可关闭您可以在命令行中运行的服务器的命令.也许有一些隐藏的东西可以重启它?
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?
更新:似乎我们需要运行"dnx-watch web",但是Visual Studio默认情况下会运行"dnx"命令.我不确定如何更改(或者是否可以将"dnx"更改为"dnx-watch"
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"
推荐答案
这是我根据@tugberk的回答所做的事情.
Here's what I did based on @tugberk's answer.
- 安装了dnx-watch命令:
dnu命令安装Microsoft.Dnx.Watcher
- 在'devDependencies'下将gulp-shell添加到package.json中
- 在gulpfile.js中添加了
var shell = require('gulp-shell');
- 将
gulp.task('watch',shell.task(['dnx-watch web']));
添加到gulpfile.js - 如果您希望在打开项目时运行
dnx-watch
,请将"watch"任务添加为项目打开在Task Runner Explorer中的绑定.
- 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.
现在,如果您更改代码并按ctrl + s,则dnx-watch将重新启动您的应用程序,而无需显式构建项目.
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.
这篇关于如何使用Visual Studio动态更新Kestrel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!