Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging in vscode with multiple dotnet core projects under one solution

I have setup my project in vscode with a root "solution" containing a global.json defining the sub projects. These are currently my web app, and a class library.

That works fine, and I have setup the following launch.json under the root directory in an attempt to debug my web app:

{
"version": "0.2.0",
"configurations": [
    {
        "name": "WebApp",
        "type": "coreclr",
        "request": "launch",
        "preLaunchTask": "",
        "program": "${workspaceRoot}/WebApp/bin/Debug/netcoreapp1.0/WebApp.dll",
        "args": [],
        "cwd": "${workspaceRoot}/WebApp/",
        "stopAtEntry": false,
        "launchBrowser": {
            "enabled": true,
            "args": "${auto-detect-url}",
            "osx": {
                "command": "open"
            }
        }
    }
]

}

I have two issues with this.

  1. I had to remove the preLaunchTask build because it tries to build from the root dir. Not ideal but I can work around that by building manually first.

  2. When the debugger launches, it fails to find the source code because its looking in the root dir, rather than the sub project. This one is a show stopper because I can't use breakpoints at all without the source loaded.

Is there a way around these issues?

Update: 9th August 2016

I took the issue to Omnisharp directly and got a bit further, being able to debug an app and a separate library under one solution. Haven't quite hit the jackpot on multiple executable projects under one solution yet though. Unfortunately I'm not pursuing that project any longer but hopefully this can help someone towards a total solution.

Link to discussion and code samples: https://github.com/OmniSharp/omnisharp-vscode/issues/460#issuecomment-228392486

like image 943
matthewrk Avatar asked May 22 '16 15:05

matthewrk


People also ask

Can we open multiple projects in Visual Studio Code?

Or you can just select multiple folders and then click open. Save this answer. Show activity on this post. Just put your projects in the same folder and simply open that folder in vscode.

Can Visual Studio run two projects at once?

Visual Studio allows you to specify how more than one project is run when you press F5 (Start with Debugging), or Ctrl+F5 (Start without debugging), or use the toolbar button to launch your application.


1 Answers

I had the same problem, and I have the following structure for my solution:

global.json
|src
--|TestApp
----Program.cs
----project.json
--|ExtLib
----ExtLibClass.cs
----project.json

in the task.json file in the .vscode folder you have to set the options value like this:

"command": "dotnet",
"isShellCommand": true,
"options": {
    "cwd": "${workspaceRoot}/src/TestApp"
},

and in the launch.json file in the .vscode folder you have to change the program property like this:

"configurations": [
    {
        "name": "TestApp Debug",
        "type": "coreclr",
        "request": "launch",
        "preLaunchTask": "build",
        "program": "${workspaceRoot}/src/TestApp/bin/Debug/netcoreapp1.0/TestApp.dll",
        "args": [],
        "cwd": "${workspaceRoot}/src/TestApp",

So I can debug multiple projects in a solution in visual studio code.

like image 90
Pukka Avatar answered Nov 03 '22 21:11

Pukka