tasks.json 4.1 KB
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            // 构建整个解决方案
            "label": "build",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/HaHRCS.sln",
                "/property:GenerateFullPaths=true",
                "/consoleloggerparameters:NoSummary"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "problemMatcher": "$msCompile"
        },
        {
            // 构建并启动 Docker 服务
            "label": "docker-build",
            "dependsOrder": "parallel",
            "dependsOn": [
                "docker-start-services",
                "build"
            ],
            "group": {
                "kind": "build",
                "isDefault": false
            }
        },
        {
            // 启动所有 Docker 服务
            "label": "docker-start-services",
            "type": "shell",
            "command": "docker-compose",
            "options": {
                "cwd": "${workspaceFolder}/src"
            },
            "args": [
                "up",
                "-d",
                "--remove-orphans"
            ],
            "group": "build",
            "presentation": {
                "reveal": "always",
                "panel": "shared"
            },
            "problemMatcher": []
        },
        {
            // 停止所有 Docker 服务
            "label": "docker-stop-services",
            "type": "shell",
            "command": "docker-compose",
            "options": {
                "cwd": "${workspaceFolder}/src"
            },
            "args": [
                "down"
            ],
            "group": "build",
            "presentation": {
                "reveal": "always",
                "panel": "shared"
            },
            "problemMatcher": []
        },
        {
            // 清理构建
            "label": "clean",
            "command": "dotnet",
            "type": "process",
            "args": [
                "clean",
                "${workspaceFolder}/HaHRCS.sln"
            ],
            "group": "build",
            "problemMatcher": "$msCompile"
        },
        {
            // 恢复 NuGet 
            "label": "restore",
            "command": "dotnet",
            "type": "process",
            "args": [
                "restore",
                "${workspaceFolder}/HaHRCS.sln"
            ],
            "group": "build",
            "problemMatcher": "$msCompile"
        },
        {
            // 发布构建
            "label": "publish",
            "command": "dotnet",
            "type": "process",
            "args": [
                "publish",
                "${workspaceFolder}/src/Rcs.Api/Rcs.Api.csproj",
                "--configuration",
                "Release",
                "--output",
                "${workspaceFolder}/publish"
            ],
            "group": "build",
            "problemMatcher": "$msCompile"
        },
        {
            // 运行测试(当测试项目存在时)
            "label": "test",
            "command": "dotnet",
            "type": "process",
            "args": [
                "test",
                "${workspaceFolder}/HaHRCS.sln",
                "--logger",
                "console",
                "--verbosity",
                "normal"
            ],
            "group": "test",
            "problemMatcher": "$msCompile"
        },
        {
            // 检查 Docker 服务状态
            "label": "docker-status",
            "type": "shell",
            "command": "docker-compose",
            "options": {
                "cwd": "${workspaceFolder}/src"
            },
            "args": [
                "ps"
            ],
            "group": "build",
            "presentation": {
                "reveal": "always",
                "panel": "shared"
            },
            "problemMatcher": []
        }
    ]
}