Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Purpose of dotnetRunMessages in launchSettings.json

In ASP.NET Core 5 the template provides this in launchSettings.json:

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

dotnetRunMessages is not documented anywhere. What does it do?

like image 928
lonix Avatar asked Jan 27 '21 16:01

lonix


People also ask

What is the launchsettings JSON file used for?

(C# ASP.NET Core) The launchSettings.json File and launch Profiles | We learn about the finer details of launchSettings.json file. This file contains various launch profiles to start an application in various modes - such as InProcess, OutOfProcess and direct Kestrel.

What is launchsettings in ASP NET Core?

The launchSettings.json file is used to store the configuration information, which describes how to start the ASP.NET Core application, using Visual Studio. The file is used only during the development of the application using Visual Studio. It contains only those settings that required to run the application.

What is the JSON file in ASP NET 5?

BTW ASP.NET 5 is now ASP.NET Core 1.0. This json file holds project specific settings associated with each debug profile, Visual Studio is configured to use to launch the application, including any environment variables that should be used. You can define framework for your project for compilation and debugging for specific profiles.

How do I create a launchsettings example for a web application?

Create a new ASP.NET core web application with the name LaunchSettingsExample. Choose .NET Core & ASP.NET Core 3.1. You will see the following contents in the launchSettings.json file


1 Answers

The whole purpose of this setting, which indeed is not yet officially documented anywhere as far as I can tell, is to give some immediate feedback upon running dotnet run or dotnet watch inside of a terminal.

Without it set to true, on the first run after creating a new .net core/ .net 5 app, it might take a few seconds before some actual text feedback is shown, which might confuse the user.

It was started by this issue on GitHub: https://github.com/dotnet/sdk/issues/12227, where you can find more details about the reasoning behind it.


Beside that, if you want to leverage the power of dotnet watch inside VS 2019, it's also better to have this flag set to true, since the messages that get to the console seem to be more verbose.

"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"
}
like image 56
Mihai Paraschivescu Avatar answered Sep 21 '22 07:09

Mihai Paraschivescu