如何监视文件更改“dotnet watch"使用 Visual Studio ASP.NET Core [英] How to watch for file changes "dotnet watch" with Visual Studio ASP.NET Core

查看:24
本文介绍了如何监视文件更改“dotnet watch"使用 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 website using just F5 or Ctrl+F5 (not using the 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 the 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.

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆