skip to Main Content

I have a solution with multiple console apps and I want to debug the selected one like in Visual Studio. Is there a way to do it?

I found that the only way for me was to delete launch.json and add it to the current project every time. But that is not very convenient.

2

Answers


  1. Chosen as BEST ANSWER

    Actually I found a solution. The only problem with adding projects to the launch.json file is that I have a lot of projects with a lot of folders and long names.

    The solution I've found is really simple! Because I use C# extension there is a setting in the User Settings - CSharp > Debug: Console, there I changed it to integratedTerminal and it fixed the issue. Now I can debug any app without using .vscode and read from the console.


  2. The configurations key in launch.json is an array. You can have multiple configurations in the launch.json, one (or more) for each of your console applications. You can read about this in the documentation

    For example:

    {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "ConsoleApp1",
                "type": "coreclr",
                "request": "launch",
                "preLaunchTask": "build",
                "program": "${workspaceFolder}/ConsoleApp1/bin/Debug/net7.0/ConsoleApp1.dll",
                "args": [],
                "cwd": "${workspaceFolder}/src/ConsoleApp1",
                "console": "internalConsole",
                "stopAtEntry": false
            },
            {
                "name": "ConsoleApp2",
                "type": "coreclr",
                "request": "launch",
                "preLaunchTask": "build",
                "program": "${workspaceFolder}/ConsoleApp2/bin/Debug/net7.0/ConsoleApp2.dll",
                "args": [],
                "cwd": "${workspaceFolder}/src/ConsoleApp2",
                "console": "internalConsole",
                "stopAtEntry": false
            }
        ]
    }
    

    After doing this, the Run and Debug dropdown will have multiple configurations. You can select the first one and start it, and then while the first one is running, go back and select the second one, and so on.

    screenshot of the run and debug dropdown showing multiple configurations

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search