nowox
nowox

Reputation: 29116

How to translate paths from C:\... to /c/... in vs-code tasks?

I would like to build my program using Git Bash or MinGW so I have this build task:

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "gcc.exe build active file",
            "command": "gcc",
            "args": ["-g", "${relativeFile}", "-o", "${fileBasenameNoExtension}"],          
            "options": {
                "shell": {
                    "executable": "C:\\Program Files\\Git\\bin\\bash.exe",
                    "args": ["-l"]
                },
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
        },      
    ]
}

I have two issues:

  1. The cwd command does not work because ${fileDirname} is in the Windows form C:\Foo\Bar and since I am on bash I would like the POSIX form /c/Foo/Bar.

  2. My task is not executed in the current terminal, but in a weird Window that display no output:

    /usr/bin/bash: gcc -g .vscode\tasks.json -o tasks: No such file or directory
    The terminal process terminated with exit code: 127
    
    Terminal will be reused by tasks, press any key to close it.
    

Upvotes: 0

Views: 239

Answers (1)

rioV8
rioV8

Reputation: 28783

With the extension Command Variable (v0.2.0) you can add Posix versions of the directory variables.

"cwd": "${command:extension.commandvariable.file.fileDirnamePosix}"

Upvotes: 1

Related Questions