Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 99131

How to create a directory in Visual Studio Code tasks.json in windows?

$
0
0

I'm trying to write a task to create a directory using Visual studio Code tasks (in tasks.json) for windows users using the mkdir command, it's working well except when the folder already exists.

tasks.json

{
    "label": "(release) create build directory",
    "type": "shell",
    "linux": {
        "command": "mkdir -p ./build/release"
    },
    "windows": {
        "command": "mkdir .\\build\\release", // Not working when folder already exists !
    }
},

What I tried:
"command": "IF NOT EXIST .\\build\\release mkdir .\\build\\release"
But then I get the error:

At line:1 char:3
+ IF NOT EXIST .\build\release mkdir .\build\release
+   ~
Missing '(' after 'IF' in if statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingOpenParenthesisInIfStatement

If it is not possible to do it this way, is it possible to run this task by ignoring the exit code ? ( so that the tasks continue to build my project)

Environment:
Visual Studio code 1.40.2
Windows 10 Pro x64


Viewing all articles
Browse latest Browse all 99131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>