Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is "dotnet run" default profile setting from launchProfile.json?

According to MS docs: https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-run?source=docs

and this SO thread How to determine which environment asp.net core app will run in?

I am still unable to determine what is dotnet run default profile setting from launchProfile.json?

Thanks, Piotr

like image 854
Piotr Śródka Avatar asked Sep 12 '25 20:09

Piotr Śródka


2 Answers

dotnet run --launch-profile "SampleApp"

This approach only supports Kestrel profiles for now using .NET 6. For e.g. the --launch-Profile only supports "SampleApp" which commandName is defined as "Project" in launchSettings.json file.

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:59481",
      "sslPort": 44308
    }
  },
  "profiles": {
    "SampleApp": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "applicationUrl": "https://localhost:7152;http://localhost:5105",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

The default profile for dotnet run will be the first profile in launchSettings.json file, regardless of the profile name and if no launch profile is specified during dotnet run. This also written in MS Learn Documents such as

ASP.NET Core in .NET 8.0 Envinroments

As the first profile listed, this profile is used by default.

.NET Aspire

If no launch profile is specified, then the first launch profile is selected by default.

like image 66
sanme98 Avatar answered Sep 14 '25 14:09

sanme98


I think the default is simply the first profile in the list.

like image 38
Jason Watmore Avatar answered Sep 14 '25 14:09

Jason Watmore