dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.88k stars 676 forks source link

How to change the launch settings port? #1756

Closed jrmcdona closed 7 years ago

jrmcdona commented 7 years ago

Environment data

.NET Command Line Tools (2.0.0)

Product Information: Version: 2.0.0 Commit SHA-1 hash: cdcd1928c9

Runtime Environment: OS Name: Windows OS Version: 10.0.15063 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\2.0.0\

Microsoft .NET Core Shared Framework Host

Version : 2.0.0 Build : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

VS Code version: 1.16.0

C# Extension version: 1.12.1

I am just trying to figure out how to change the port when I launch the debugger. Right now it launches with 5000 by default.


Here is an example of the launch setting where I would like to change the port.

{
   "version": "0.2.0",
   "configurations": [
        {
            "name": ".NET Core Launch (web)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            // If you have changed target frameworks, make sure to update the program path.
            "program": "${workspaceRoot}/bin/Debug/netcoreapp2.0/Ambassadors.Admin.Web.dll",
            "args": [],
            "cwd": "${workspaceRoot}",
            "stopAtEntry": false,
            "internalConsoleOptions": "openOnSessionStart",
            "launchBrowser": {
                "enabled": true,
                "args": "${auto-detect-url}",
                "windows": {
                    "command": "cmd.exe",
                    "args": "/C start ${auto-detect-url}"
                },
                "osx": {
                    "command": "open"
                },
                "linux": {
                    "command": "xdg-open"
                }
            },
            "env": {
                "ASPNETCORE_ENVIRONMENT": "Development"
            },
            "sourceFileMap": {
                "/Views": "${workspaceRoot}/Views"
            }
        },
        {
            "name": ".NET Core Attach",
            "type": "coreclr",
            "request": "attach",
            "processId": "${command:pickProcess}"
        }
    ]
}
gregg-miskelly commented 7 years ago

This isn't really a C# extension question but rather an ASP.NET question. So you may have better luck asking the question on an ASP.NET repo.

TheRealPiotrP commented 7 years ago

your project should have a launchSettings.json file similar to this one:

  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:12345/",
      "sslPort": 0
    }
  },

There will be entries for iis, Project, etc. The applicationUrl will configure the port that is used by the app.

This page has some details regarding the launchSettings file. If you don't find the answer you're looking for, I'd open an issue on https://github.com/aspnet/home.

nikoudel commented 6 years ago

launchSettings.json is not read when launching with vscode (using launch.json). Environment variable ASPNETCORE_URLS should be used instead:

"env": {
    "ASPNETCORE_ENVIRONMENT": "Development",
    "ASPNETCORE_URLS": "http://localhost:4000/"
}