Steps to Reproduce:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "typescript",
"tsconfig": "tsconfig.json",
"problemMatcher": [
"$tsc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
> Executing task: tsc -p "d:\Temp\Space here\tsconfig.json" <
error TS5042: Option 'project' cannot be mixed with source files on a command line.
The terminal process terminated with exit code: 1
Terminal will be reused by tasks, press any key to close it.
> Executing task: tsc -p "d:\Temp\Space_NOT_here\tsconfig.json" <
Terminal will be reused by tasks, press any key to close it.
Additional information:
Although the displayed command looks fine and will actually work if you Copy&Paste it into a Terminal window: tsc -p "d:TempSpace heretsconfig.json"
the error message is consistent with what you'd get if you remove the quotes, which suggests they weren't there when the command was actually executed as a task by VS
EDIT: fix markdown issue
This is a little bit a chicken egg problem which we were discussing how to best solve. The problem is that the creator of the task doesn't know which shell is used to execute hence doesn't really no how to quote / escape these things and the task executing engine doesn't know the structure of the command. The only possible way I can imagine is that the creator of the tasks give hint which parts should be escaped.
Same problem on macOS. As a workaround I'm launching tsc as type shell command:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"label": "typescript",
"tasks": [{
"taskName": "typescript",
"type": "shell",
"command": "tsc",
"problemMatcher": "$tsc",
"args": ["-p", "\"${workspaceFolder}/tsconfig.json\""],
"group": {
"kind": "build",
"isDefault": true
}
}]
}
Fixed in latest.
To verify:
@dbaeumer I stumbled over this issue aswell and was wondering if that is in insider yet cause even with insider it breaks for me but with a different error:
VS 1.21.1 had:
> Executing task: c:\Dev\chromajs sample\node_modules\.bin\tsc.cmd --watch -p "c:\Dev\chromajs sample\tsconfig.json" <
c:\Dev\chromajs : The term 'c:\Dev\chromajs' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:1
+ c:\Dev\chromajs sample\node_modules\.bin\tsc.cmd --watch -p c:\Dev\ch ...
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (c:\Dev\chromajs:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
VS 1.22.0-insider with commit hash that is 19 hours ago (a716373aaaf50cbce3618688a645b324721b35dd):
> Executing task: 'c:\Dev\chromajs sample\node_modules\.bin\tsc.cmd' --watch -p 'c:\Dev\chromajs sample\tsconfig.json' <
At line:1 char:54
+ 'c:\Dev\chromajs sample\node_modules\.bin\tsc.cmd' --watch -p 'c:\Dev ...
+ ~~~~~
Unexpected token 'watch' in expression or statement.
At line:1 char:1
+ 'c:\Dev\chromajs sample\node_modules\.bin\tsc.cmd' --watch -p 'c:\Dev ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The '--' operator works only on variables or on properties.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
Without spaces everything works fine....
I will reopen the issue.
OK. I only tested it with a global installed tsc. Need to dig why --watch now is interpreted as an expression in PowerShell.
OK. If the command is quoted I need to put a & in front :-)
@WolfspiritM thanks for bringing that to my attention
Most helpful comment
To verify: