launchSettings.json 中 dotnetRunMessages 的用途

Purpose of dotnetRunMessages in launchSettings.json

在 ASP.NET Core 5 中,模板在 launchSettings.json 中提供了此内容:

"MyProject": {
  "commandName": "Project",
  "dotnetRunMessages": "true",    // <<<<<<<<
  "launchBrowser": true,
  "applicationUrl": "https://localhost:5001;http://localhost:5000",
  "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Development"
  }
},

dotnetRunMessages 未在任何地方记录。它有什么作用?

此设置的全部目的(据我所知确实尚未在任何地方正式记录)是在 运行 宁 dotnet run 或 [=12= 时提供一些即时反馈] 在终端内部。

如果不将其设置为 true,在创建新的 .net core/.net 5 应用程序后的第一个 运行,可能需要几秒钟才能显示一些实际的文本反馈,这可能会使用户感到困惑。

它是从 GitHub 上的这个问题开始的:https://github.com/dotnet/sdk/issues/12227,您可以在其中找到有关其背后原因的更多详细信息。


除此之外,如果您想在 VS 2019 中利用 dotnet watch 的强大功能,最好将此标志设置为 true,因为到达控制台的消息似乎更冗长。

"API Watch": {
  "commandName": "Executable",
  "executablePath": "dotnet",
  "commandLineArgs": "watch run",
  "workingDirectory": "$(ProjectDir)",
  "launchBrowser": true,
  "applicationUrl": "https://localhost:5001;http://localhost:5000",
  "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Development"
  },
  "dotnetRunMessages": "true"
}