LoginSignup
6
6

More than 5 years have passed since last update.

VSCode+bashのときのビルドタスク設定のファイルパス指定方法

Last updated at Posted at 2018-02-27

内容

vscodeのビルドタスク設定を検索すると、
argsオプションがだいたい${file}となっている.

これは今開いているファイルの絶対パスを渡すオプションだが、
bashを使ってると、パス区切りの\がエスケープされてしまい、
ビルドエラーというかパスがないよって怒られてしまう.

なので、相対パスを渡す${relativeFile}を指定してやればよい.
こっちはパス区切りが/になるので問題なし.

使用環境

Visual Studio Code ver1.20.1
Git bash

記述例

tasks.json
{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Python",
            "type": "shell",
            "command": "python",
            "args": [
                "${relativeFile}"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

参考リンク

6
6
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
6
6