Skip to content

How to Build and Debug multiple .NET projects in Visual Studio Code (vscode)

License

Notifications You must be signed in to change notification settings

imaun/vscode-mutliple-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vscode-mutliple-project

How to Build and Debug multiple .NET projects in Visual Studio Code (vscode)

Suppose we have mutliple projects with a structure like this :

- src
  - SampleProject.Api
    - SampleProject.Api.csproj
  - SampleProject.Console
    - SampleProject.Console.csproj
  - SampleProject.Lib
    - SampleProject.Lib.csproj

Note that we don't have a solution file here. But with a solution, it's not very different.

  • Create a directory named .vsocde in your working directory root.
  • Create a file inside .vscode and name it tasks.json -> task.json
  • Create another file inside .vscode and name it launch.json -> launch.json

For debugging .NET application we must install omnisharp plugin on vscode.

Tasks

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build Lib",
            "command": "dotnet",
            "type": "shell",
            "args": [
                "build",
                "${workspaceFolder}/src/SampleProject.Lib"
            ],
            "problemMatcher": [
                "$msCompile"
            ],
            "presentation": {
                "reveal": "always"
            },
            "group": "build"
        },
        {
            "label": "build Api",
            "command": "dotnet",
            "type": "shell",
            "args": [
                "build",
                "${workspaceFolder}/src/SampleProject.Api"
            ],
            "problemMatcher": "$msCompile",
            "presentation": {
                "reveal": "always"
            },
            "group": "build"
        },
        {
            "label": "build Console",
            "command": "dotnet",
            "type": "shell",
            "args": [
                "build",
                "${workspaceFolder}/src/SampleProject.Console"
            ],
            "problemMatcher": "$msCompile",
            "presentation": {
                "reveal": "always"
            },
            "group": "build"
        }
    ]
}

Launch

{
    "configurations": [
    {
        "name": "Api",
        "type": "coreclr",
        "request": "launch",
        "preLaunchTask":  "build Api",
        "program": "${workspaceFolder}/src/SampleProject.Api/bin/Debug/net6.0/SampleProject.Api.dll",
        "args": [],
        "cwd": "${workspaceFolder}/src/SampleProject.Api",
        "stopAtEntry": false,
        "console": "externalTerminal"
    },
    {
        "name": "Console",
        "type": "coreclr",
        "request": "launch",
        "preLaunchTask": "build Console",
        "program": "${workspaceFolder}/src/SampleProject.Console/bin/Debug/net6.0/SampleProject.Console.dll",
        "args": [],
        "cwd": "${workspaceFolder}/src/SampleProject.Console",
        "stopAtEntry": false,
        "console": "integratedTerminal"
    }],
    "compounds": [
        {
            "name": "Debug All",
            "configurations": [
                "Api",
                "Console"
            ]
        }
    ]
}

Now we can go to Debug tab and debug one or all our applications we already definded in launch.json file. How to debug multiple projects in vscode


About

How to Build and Debug multiple .NET projects in Visual Studio Code (vscode)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages