Asp.net-Core

launchSettings.json 中 dotnetRunMessages 的用途

  • January 27, 2021

在 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 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"
}

引用自:https://stackoverflow.com/questions/65923063