Error after modifying launchSettings: The launch profile "(Default)" could not be applied

Viewed 4334

I'm setting up my project to use dotnet watch run in my launchSettings.json under Visual Studio 2019 Preview 16.9.0

Below is my launchSettings.json

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

Here is the ouput when I hit CTRL+F5

watch : Started
The launch profile "(Default)" could not be applied.
A usable launch profile could not be located.
[17:38:49 INF] Starting up
[17:38:49 INF] User profile is available. Using 'C:\Users\MyUser\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
[17:38:50 INF] Now listening on: http://localhost:5000
[17:38:50 INF] Now listening on: https://localhost:5001
[17:38:50 INF] Application started. Press Ctrl+C to shut down.
[17:38:50 INF] Hosting environment: Development
[17:38:50 INF] Content root path: C:\dev\MyWebsite\src\MyWebsite

I don't understand why I have this message :

The launch profile "(Default)" could not be applied.
A usable launch profile could not be located.

According to this solution https://stackoverflow.com/a/65666418/1026105 this is not supposed to happen.

How can I troubleshoot this messages ?

2 Answers

just Change

"MyWebsite": { "commandName": "Executable",

to

"MyWebsite": { "commandName": "Project",

For me, changing commandName from Executable to Project made the error message go away, but also disabled the dotnet watch behaviour altogether.

I fixed the issue by adding a separate Project profile as well as the Executable one - I assume the Project profile then serves as the 'default' profile to which the error message refers.

So it's:

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