如何监视文件更改

如何监视文件更改

本文介绍了如何监视文件更改?使用Visual Studio ASP.NET Core的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Visual Studio与ASP.NET Core一起使用,并仅使用F5或Ctrl + F5(而不是直接使用命令行)来运行网站.我想使用"dotnet watch"功能来确保所有更改都在进行中,以避免再次启动服务器.似乎在命令行中您将为此使用"dotnet watch run",但是Visual Studio使用launchSettings.json并在我理解正确的情况下在后台进行操作.

I am using Visual Studio with ASP.NET Core and run the web site using just F5 or Ctrl+F5 (not using command line directly). I would like to use the "dotnet watch" functionality to make sure all changes are picked up on the fly to avoid starting the server again. It seems that with command line you would use "dotnet watch run" for this, but Visual Studio uses launchSettings.json and does it behind the scenes if I understand it correctly.

如何在那里连接"dotnet watch"?

How can I wire up "dotnet watch" there?

推荐答案

打开launchSettings.json并将其添加到profiles.

Open launchSettings.json and add this to 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.

Open project.json and add this to tools.

"Microsoft.DotNet.Watcher.Tools": "1.0.0-preview2-final"

还原后,我们可以在Visual Studio中观看.

After restoring, we can Watch from within Visual Studio.

这篇关于如何监视文件更改?使用Visual Studio ASP.NET Core的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 00:47