Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build all C# projects in VS Code using only one command in tasks.json?

In VS Code, I have the following C# projects:

 - Common/Common.csproj
 - WebApi1/WebApi1.csproj
 - WebApi2/WebApi2.csproj

And my tasks.json is the following:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/WebApi1/WebApi1.csproj"
            ],
            "problemMatcher": "$msCompile"
        }
    ]
}

When I hit debug selecting the WebApi1 profile, my launch.json runs the task build (defined in the previous code section) and this tasks builds the WebApi1.csproj project alongs with Common.csproj, because Common is defined as a dependency.

My question is: how can I use the same task to build WebApi1 AND the WebApi2 (and WebApi3, WebApi4, etc.), which means one task to build all projects in the repo.

I've tried "${workspaceFolder}/**/*.csproj" but this syntax was not accepted.

like image 598
cash Avatar asked Mar 27 '26 20:03

cash


1 Answers

As a possible solution, you can place all your projects into one single solution and specify in a build task, something like that

"tasks": [
        {
            "label": "build",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/solution.sln"
            ],
            "problemMatcher": "$msCompile"
        }
    ]
like image 140
Pavel Anikhouski Avatar answered Mar 29 '26 09:03

Pavel Anikhouski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!