DEV Community

Discussion on: Build and Debug C++ Application with VSCode and MSVC

Collapse
 
shockvawe profile image
Yusuf Umut Piynar

Oh man, I am working on a bug from this code for almost 3 hours by now. I am not used to Windows environment and batch scripting. I challenged myself to use MSVC but I didn't know that it would be this hard.
In your tasks.json there's a line:
"command": "if not exist ${config:buildDir} mkdir ${config:buildDir}"
This line gives an error:
At line:1 char:3

  • if not exist C:\Users\aurus\Desktop\C\build mkdir C:\Users\aurus\Desk ...
  • ~ Missing '(' after 'if' in if statement.
    • CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
    • FullyQualifiedErrorId : MissingOpenParenthesisInIfStatement

I even learned the syntax of batch scripting and did some examples in the Powershell as a complete linux user yet I couldn't figure out why the f this line gives this error.

I would appreciate some enlightment.

Collapse
 
shockvawe profile image
Yusuf Umut Piynar

Solved the issue, took my 4 hours. Just switching VSCODE terminal to CMD from PS would probably solve the issue (or maybe not idk) but this definitely does.

Change the problematic line with this:

"command": "cmd",
"args": ["/C", "if not exist ${config:buildDir} mkdir ${config:buildDir}"]

Collapse
 
masoudr profile image
Masoud Rahimi

Hi, I'm sorry I haven't check the community for a while.
Yes you are right you need the set CMD as default shell because scripts are based on it.