'VSCode using relative paths in build task on remote set up

I'm trying to add a build task to build the current file, just a simple "make path/to/file.o". I'm using vscode on windows 10 over a remote SSH connection to linux.

However, if I use ${relativeFileDirname} it converts the path separators to windows format. Eg...

${fileDirname}=/home/me/git/project/data/source
${relativeFileDirname}=data\source

I've read about explorer.copyRelativePathSeparator. Can that be applied to the build task in tasks.json? Or is there another way?

This is the build task...

{
    "type": "cppbuild",
    "label": "C/C++: gcc build active file",
    "command": "/usr/bin/make",
    "args": [
        "${relativeFileDirname}/${fileBasenameNoExtension}.o"
    ],
    "options": {
        "cwd": "/home/me/git/project"
    },
    "problemMatcher": [
        "$gcc"
    ],
    "group": {
        "kind": "build",
        "isDefault": true
    },
    "detail": "compiler: /usr/bin/gcc",
    "presentation": {
        "clear": true
    }
}

Thanks.



Solution 1:[1]

There is an extension for Visual Studio Code for this purpose that, after many failed attempts to use string substitution with bash built-ins and sed, was the only working solution for me:

"customOptions": "--workdir /home/user/${command:extension.commandvariable.file.relativeFileDirnamePosix}",

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 fuenfundachtzig