launchSettings.json 中 dotnetRunMessages 的用途

lon*_*nix 12 asp.net-core asp.net-core-5.0

在 ASP.NET Core 5 中,模板在launchSettings.json以下位置提供:

"MyProject": {
  "commandName": "Project",
  "dotnetRunMessages": "true",    // <<<<<<<<
  "launchBrowser": true,
  "applicationUrl": "https://localhost:5001;http://localhost:5000",
  "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Development"
  }
},
Run Code Online (Sandbox Code Playgroud)

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

mik*_*est 15

这个设置的全部目的,据我所知,确实还没有正式记录在任何地方,就是在运行时立即提供一些反馈 dotnet rundotnet watch在终端内部。

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

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


除此之外,如果您想利用dotnet watchVS 2019 内部的强大功能,最好将此标志设置为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"
}
Run Code Online (Sandbox Code Playgroud)