LoginSignup
5
5

More than 5 years have passed since last update.

Visual Studio Code: Task 機能のクロスプラットフォーム対応

Last updated at Posted at 2015-12-08

概要

Visual Studio Code を一般的なプロジェクトへ適用する際にはしばしば Task 機能で実行するコマンドをプラットフォーム毎に特殊化したい需要に遭遇する。

1つの解決手段としては多くのプラットフォームで動作するシェルプログラムなどを各環境へ導入する事を前提としてしまう事だが、Visual Studio Code の Task にはプラットフォームに応じてコマンドを特殊化する機構が組み込まれており、これを用いればより簡易に Task のクロスプラットフォーム対応を、柔軟に行えるから紹介したい。

背景

Windows, Linux, OSX の何れも開発環境としたプロジェクトは近年一般的な多くのアプリケーション開発でも一掃重要性が高まっている。Visual Studio Code のプロジェクト設定として開発環境ごとのクロスプラットフォーム対応をはかることで参加する開発者への負担を軽減しより円滑で柔軟な開発体制を実現したい。

方法

次の例では windows 環境では cmd /c 、それ以外の環境では sh -c が top-level のコマンドと引数として実行される。

{ "command": "sh"
, "args": ["-c"]
, "windows":
  { "command": "cmd"
  , "args": ["/c"]
  }
, "tasks":
  [ { "taskName": "hoge"
    , "suppressTaskName": true
    , "isBuildCommand": true
    , "args": ["ninja -v"]
    }
  ]
}

執筆現在使っている vscode-0.10.3 では "windows" のほか、 "linux" あるいは "osx" への特殊化に対応している。

References

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5