Search code examples
.netasp.net-coredotnet-cli.net-6.0

dotnet watch ignores portnumber launchsettings.json after upgrade to .NET 6


  1. When I run my ASP.NET Core (Blazor Server) app using Visual Studio, it listens on port 5003,
  2. when using dotnet watch --project app\App.csproj run, it listens on different port - 5001!

Here is my launchSettings.json

"App": {
  "commandName": "Project",
  "dotnetRunMessages": "true",
  "launchBrowser": true,
  "applicationUrl": "https://localhost:5003;http://localhost:5002",
  "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Development",
    "LocalUrl": "https://localhost:5003"
  }
}

Why the dotnet run starts on different port and how to make it to run on 5003?


Addional info:

The app was created in .NET 5 and the problem occured after upgraded the SDK and PackageReferences .NET 6,


Solution

  • It's a known bug in .NET 6, see: