2

我想链接一些我在tasks.json.

我有许多不同的子项目(C#csproj文件)应该被构建,然后在一个大的单一任务中测试(shell 命令)。

我有这个tasks.json工作,但我只能一一调用不同的命令。

4

2 回答 2

1

更新

在得到进一步澄清之后,您可以在 Visual Studio 中将您要完成的任务配置为构建后步骤。为将要构建的最后一个项目配置命令。

在此处输入图像描述

原始答案


您可以并行执行任务:

public class TaskCollection
{
    public string version { get; set; }
    public List<Task> tasks { get; set; }
    public static void RunTasks()
    {
        string json = new WebClient().DownloadString("https://gist.githubusercontent.com/eppz/f941f2e85e12e7cc81c63ee2ac1354e5/raw/fa15f7b9774083f481504677b96353fe0da777be/tasks.json");
        TaskCollection col = new JavaScriptSerializer().Deserialize<TaskCollection>(json);
        Parallel.ForEach(col.tasks, (x) =>
        {
            ExecuteTask(x);
        }
        );
    }

    private static void ExecuteTask(Task x)
    {
        //Do something
    }
}

public class Task
{
    public string taskName { get; set; }
    public bool isBuildCommand { get; set; }
    public string command { get; set; }
    public string[] args { get; set; }
    public string showOutput { get; set; }
    public string problemMatcher { get; set; }
    public bool isShellCommand { get; set; }
    public bool isTestCommand { get; set; }
}
于 2017-07-08T01:09:00.807 回答
1

dependsOn哇,从 1.10 开始就有一个属性。
请参阅发行说明中有关 Terminal Runner 的更多工作。

{
    "version": "2.0.0",
    "tasks":
    [
        {
            "taskName": "Build",
            "isBuildCommand": true,
            "command": "/Applications/Unity/Unity.app/Contents/MonoBleedingEdge/bin/xbuild",
            "args":
            [
                "Project.sln",
                "/property:GenerateFullPaths=true"
            ],
            "showOutput": "silent",
            "problemMatcher": "$msCompile"
        },
        {
            "taskName": "Build EPPZ.Extensions.Test",
            "command": "/Applications/Unity/Unity.app/Contents/MonoBleedingEdge/bin/xbuild",
            "args":
            [
                "Assets/Plugins/eppz!/Extensions/Test.csproj",
                "/property:Configuration=Local",
                "/property:GenerateFullPaths=true"
            ],
            "showOutput": "always",
            "problemMatcher": "$msCompile"
        },
        {
            "taskName": "Test EPPZ.Extensions.Test",
            "isShellCommand": true,
            "command": "mono",
            "dependsOn": [ "Build EPPZ.Extensions.Test" ],
            "args":
            [
                "/Users/eppz/Projects/Unity/Packages/NUnit/NUnit.ConsoleRunner.3.6.1/tools/nunit3-console.exe",
                "bin/EPPZ.Extensions.Test.dll",
                "--labels=All",
                "--result=EPPZ.Extensions.Test.Result.xml"
            ],
            "showOutput": "always"
        },
        {
            "taskName": "Test",
            "isShellCommand": true,
            "isTestCommand": true,
            "command": "echo",
            "args": ["All done."],
            "dependsOn": [ "Test (EPPZ.Extensions.Test)" ],
            "showOutput": "always"
        }
    ]
}
于 2017-07-08T01:48:48.710 回答