我正在使用带有ASP.NET Core的Visual Studio并仅使用F5或Ctrl+F5(不直接使用命令行)运行网站。我想使用“dotnet watch”功能来确保所有的更改都是即时获得的,以避免再次启动服务器。在命令行中,您似乎会使用“dotnet watch run”来执行此操作,但Visual Studio使用launchsettings.json,如果我没有理解错的话,则在后台执行此操作。
我怎样才能在那里安装“DotNet Watch”?
打开LaunchSettings.json并将其添加到profiles
。
"Watch": {
"executablePath": "C:\\Program Files\\dotnet\\dotnet.exe",
"commandLineArgs": "watch run",
"launchBrowser": true,
"launchUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
打开project.json并将其添加到tools
中。
"Microsoft.DotNet.Watcher.Tools": "1.0.0-preview2-final"
还原后,我们可以从Visual Studio中观看。
如果您希望使用ASP.NET2.x或3.x,则需要对其稍作更改。
>
语法略有不同
"Watch": { "executablePath": "dotnet.exe", "workingDirectory": "$(ProjectDir)", "commandLineArgs": "watch run", "launchBrowser": true, "launchUrl": "http://localhost:5000/", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } }
更新:添加“workingdirectory”并删除特定路径。现在更通用了。