c# - 如何仅使用 tasks.json 中的一个命令在 VS Code 中构建所有 C# 项目?

标签 c# .net visual-studio-code

在 VS Code 中,我有以下 C# 项目:

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

还有我的 tasks.json如下:
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/WebApi1/WebApi1.csproj"
            ],
            "problemMatcher": "$msCompile"
        }
    ]
}

当我点击调试选择 WebApi1 配置文件时,我的 launch.json运行任务 build (在前面的代码部分中定义)并且此任务构建 WebApi1.csproj项目与 Common.csproj ,因为 Common 被定义为依赖项。

我的问题是:如何使用相同的任务来构建 WebApi1 和 WebApi2(以及 WebApi3、WebApi4 等),这意味着在 repo 中构建所有项目的任务。

我试过 "${workspaceFolder}/**/*.csproj"但这种语法不被接受。

最佳答案

作为一种可能的解决方案,您可以将所有项目放在一个解决方案中并在构建任务中指定,类似这样

"tasks": [
        {
            "label": "build",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/solution.sln"
            ],
            "problemMatcher": "$msCompile"
        }
    ]

关于c# - 如何仅使用 tasks.json 中的一个命令在 VS Code 中构建所有 C# 项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59361548/

相关文章:

visual-studio-code - VSCode 支持 JSHint 和 JSCS

visual-studio-code - Jest Puppeteer - 为其设置 Visual Studio Code

c++ - 链接器未看到我的 Class.cpp

c# - 为什么窗体关闭时后台线程不退出?

c# - Ninject 基于约定的绑定(bind)将在运行时解析

c# - View 状态 MAC 的验证失败。应用程序由 Web 场托管,确保 <machineKey> 配置

c# - 来自运行时数据层的 C# 中的动态 odata 服务

c# - 使用具有通用输入和输出的函数

c# - 创建一个周生成器,显示周号、一周第一天、给定日期一周的最后一天

c# - 在没有回发的情况下重置 ASP.NET 中的页面