私はがいくつかのコマンド/タスクをチェーンしたいと思っています私はtasks.json
で定義しました。同じコマンドで複数のタスクを実行しますか?
ビルドしてから、大きなシングルタスクでテスト(シェルコマンド)しなければならない多くの異なるサブプロジェクト(C#csproj
ファイル)があります。
これはtasks.json
ですが、私は1つずつ異なるコマンドを呼び出すことができます。
私はがいくつかのコマンド/タスクをチェーンしたいと思っています私はtasks.json
で定義しました。同じコマンドで複数のタスクを実行しますか?
ビルドしてから、大きなシングルタスクでテスト(シェルコマンド)しなければならない多くの異なるサブプロジェクト(C#csproj
ファイル)があります。
これはtasks.json
ですが、私は1つずつ異なるコマンドを呼び出すことができます。
うわー、1.10以来dependsOn
プロパティがあります。
リリースノートのMore work on 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"
}
]
}
良い発見。私はタスクのためのドキュメントに 'dependsOn'の言及がないので彼らは彼らのドキュメントを更新する必要があります。これはまさに私が探していたものですが、本質的に逆の順序でタスクを定義する必要があるのは奇妙です。 –
ええ、私はGitHubでこれをいくつかのランダムな 'tasks.json'のどこかに見つけました。 – Geri
更新
はさらに説明を取得した後、あなたが達成しようとしているものは、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; }
}
うわー、あなたは速いです。私は '.csproj'ファイルにコマンドを張り付けることができるので、これをオプションとして考えていましたが、これをVSコードで指定して整理して明示的にしたいと思います。 – Geri
このコードをスタンドアロンの '.csproj'ファイルに入れ、タスクとして実行することができます。 jsonの設定を使用して、その動作を制御することができます。たとえば、単体テストを実行してから戻る「プロセス」を開始します。ユニットテストは実行されますが、ユニットテストが完了するのを待っているわけではないので、VSCodeは次のタスクを続行できます。 –
あなたはそれらを1つずつ呼び出すことができますか?達成しようとしていることの詳細を提供できますか? –
もちろん、帰ってくれてありがとう。私はボタンを押して、次に私の6つのサブプロジェクトを構築し、6つのテストコマンドを実行したいと思います。実際はそれだけです。 – Geri
タスクの依存関係などを定義する方法はありますか? – Geri