Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change .Net Core 2 debugger port of VSCode

I'm using Visual Studio Code (VSCode) to code .Net Core 2.0 App and would like to use the VSCode debugger for that. I created a launch.json, which works with my frontend code, but I'd like to also debug the .Net code. However my main problem is that I am not using the default port (5000 I believe it is by default). So how can I change the port?

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": ".NET Core Launch (Management.Core)",
      "type": "coreclr",
      "request": "launch",
      "preLaunchTask": ".Net Build (all)",
      "program": "${workspaceRoot}/Management.Core/bin/Debug/netcoreapp2.0/Management.Core.dll",
      "args": [],
      "cwd": "${workspaceRoot}/CpaManagement.Core",
      "stopAtEntry": false,
      "console": "internalConsole"
    },
}

I tried to add a port: 12345 but that is not an accepted property. I also tried to add args: ['-- port=12345'] but that didn't work either.

My .Net Core App launchSettings.json as the following configuration:

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:8888/",
      "sslPort": 45678
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "api/values",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "Web": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "api/values",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "http://localhost:12345/"
    }
  }
}

P.S. The ports displayed in the question are not exactly the ones I used but that shouldn't matter for the question itself.

like image 417
ghiscoding Avatar asked Nov 28 '17 19:11

ghiscoding


People also ask

How do I change the port in VS Code?

In Solution Explorer, right-click the name of the web application and select Properties. Click the Web tab. In the Servers section, under dropdown selection for IIS Express, change the port number in the Project URL box.

How do I change VS Code debugger?

Alternatively, you can run your configuration through the Command Palette (Ctrl+Shift+P) by filtering on Debug: Select and Start Debugging or typing 'debug ' and selecting the configuration you want to debug. In addition, the debug status appears in the Status Bar showing the active debug configuration.

How do I change the debug port?

Expand the Integration Nodes folder in the Navigator view. Right-click the integration server which you want to work, and click Properties. Click Flow Debug Port on the left to display the Flow Debug Port tab. Set a port number for the debug port.

How do I change the port in .NET core?

To change the port the application is using, Open the file lunchSetting. json. You will find it under the properties folder in your project and as shown below. Inside the file, change applicationUrl port (below is set to 5000) to a different port number and save the file.


1 Answers

If about web application then you should in folder .vscode in launch.json file find line:

"env": {
 "ASPNETCORE_ENVIRONMENT":"Development"
},

and add after "ASPNETCORE_ENVIRONMENT":"Development", that: "ASPNETCORE_URLS":"http://localhost:xxxx" where xxxx - port that you want to use.

like image 95
Aliaksandr Naidzenka Avatar answered Sep 26 '22 10:09

Aliaksandr Naidzenka