我有一个简单的ASP.NET 5
Web Api应用程序,它是使用制作的yo aspnet
。我正在使用Visual Studio Code在Windows 10上工作(不想使用Visual Studio)。我想从非Windows环境模拟开发。
据我所知,roslyn
编译器应该动态地编译更改的文件。但是,当我使用以下命令运行我的应用程序时,dnu restore && dnx --watch web
应用程序启动。但是,如果我然后(dnx --watch web
仍在运行)更改代码的一小部分并刷新网页,则说明已更改。
前:
// GET: api/values
[HttpGet]
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
后:
// GET: api/values
[HttpGet]
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2", "value3" };
}
我已经检查这是否是导致缓存的原因,但事实并非如此。我在这里想念什么?
笔记:
我注意到这可能是Web服务器的原因,我正在使用Kestrel
。我的一部分project.json
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx451": { },
"dnxcore50": { }
}
我有临时解决方案,使用gulp.js:
// gulpfile.js
var gulp = require('gulp');
var bg = require("gulp-bg");
var dnxweb = null;
gulp.task('dnx:web:start', dnxweb = bg("dnx", "web"));
gulp.task('dnx:web:stop', () => {
if (!dnxweb)
return;
dnxweb.setCallback((proc) => {
if (proc.errorcode != 0)
proc.exit(proc.errorcode);
});
dnxweb.stop();
});
gulp.task('watch', () => {
gulp.watch('**/*.cs', ['dnx:web:stop', 'dnx:web:start']);
});
gulp.task('build', ['dnx:web:start', 'watch']);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句