Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with dotnet watch and launchSettings.json #46596

Closed
mehdihadeli opened this issue Feb 12, 2023 · 6 comments
Closed

Problem with dotnet watch and launchSettings.json #46596

mehdihadeli opened this issue Feb 12, 2023 · 6 comments
Labels
area-commandlinetools Includes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI feature-dotnetwatch This issue is related to the dotnet-watch command-line tool (now external)

Comments

@mehdihadeli
Copy link

Hi,
I have this launchSettings.json file:

{
  "$schema": "https://json.schemaecommerce.org/launchsettings.json",
  "profiles": {
    "Catalogs.Api.Https": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "hotReloadProfile": "aspnetcore",
      "launchUrl": "swagger",
      "applicationUrl": "https://localhost:4001;http://localhost:4000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "Catalogs.Api.Http": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "hotReloadProfile": "aspnetcore",
      "launchUrl": "swagger",
      "applicationUrl": "http://localhost:4000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "Catalogs.Api.Watch": {
      "commandName": "Project",
      "executablePath": "dotnet",
      "workingDirectory": "$(ProjectDir)",
      "hotReloadEnabled": true,
      "hotReloadProfile" : "aspnetcore",
      "commandLineArgs": "watch run -lp Catalogs.Api.Http",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

My problem is, when I want to run my watch with this command dotnet run -lp Catalogs.Api.Watch it bypasses my port that it passed in another lunchprofile -lp Catalogs.Api.Http to my watch run. I expect it run on my Catalogs.Api.Http profile port that is port 4000 but my watch always run on port 5000

@davidfowl
Copy link
Member

Is there a reason you're not just doing: dotnet watch run -lp Catalogs.Api.Http? Why the layer of indirection?

@mehdihadeli
Copy link
Author

I know about that, and it is fine in the CLI. But because IDEs and in my case Rider detect this profiles and I want to access watch profile inner my IDE not CLI, right now Rider show me Catalogs.Api.Watch but when I run this with rider it goes to run port 5000.

@davidfowl
Copy link
Member

Does it work from the command line and not in rider?

@mehdihadeli
Copy link
Author

mehdihadeli commented Feb 12, 2023

This command dotnet watch run -lp Catalogs.Api.Http in the CLI works with a correct port 4000. But if we run watch with Catalogs.Api.Watch profile and command dotnet run -lp Catalogs.Api.Watch, watch will run with incorrect port 5000.
Also, rider will run Catalogs.Api.Watch profile with incorrect port 5000.

@mehdihadeli
Copy link
Author

mehdihadeli commented Feb 12, 2023

@davidfowl According to this article I changed "commandName": "Project" in my profile like this:

    "Catalogs.Api.Watch": {
      "commandName": "Executable",
      "executablePath": "dotnet",
      "workingDirectory": "$(ProjectDir)",
      "hotReloadEnabled": true,
      "hotReloadProfile" : "aspnetcore",
      "commandLineArgs": "watch run -lp Catalogs.Api.Http",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }

And it works with correct 4000 port. Is Executable a valid .net command type? I could not find it in the docs!

@javiercn javiercn added area-commandlinetools Includes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI feature-dotnetwatch This issue is related to the dotnet-watch command-line tool (now external) labels Feb 13, 2023
@tmat
Copy link
Member

tmat commented Mar 7, 2023

This doesn't seem to be issue with dotnet-watch, or is it? If the launchProfile docs are incomplete, please file an issue on the documentation page.

@tmat tmat closed this as completed Mar 8, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Apr 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-commandlinetools Includes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI feature-dotnetwatch This issue is related to the dotnet-watch command-line tool (now external)
Projects
None yet
Development

No branches or pull requests

4 participants