Reputation: 2469
I try to put a path in tasks.json for typescript type task:
{
"version": "2.0.0",
"tasks": [
{
"identifier": "tsc-client",
"label": "tsc-client",
"type": "typescript",
"tsconfig": "src/client/tsconfig.json",
"problemMatcher": [
"$tsc"
]
},
{
"identifier": "tsc-server",
"label": "tsc-server",
"type": "typescript",
"tsconfig": "src/server/tsconfig.json",
"problemMatcher": [
"$tsc"
]
},
{
"identifier": "build-all",
"label": "build-all",
"dependsOn": ["tsc-client", "tsc-server"]
}
]
}
then in my launch.json I have:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"preLaunchTask": "tsc-client",
"name": "Launch Program",
"program": "${workspaceFolder}/server/server-repsic.js"
}
]
}
I lounch it and I obtain:
Error: The typescript task detection didn't contribute a task for the following configuration:
{
"identifier": "tsc-server",
"label": "tsc-server",
"type": "typescript",
"tsconfig": "src/server/tsconfig.json",
"problemMatcher": [
"$tsc"
]
}
The task will be ignored.
I check that in the root path I have the src/server/tsconfig.json
and src/client/tsconfig.json
. Also I type it in the console:
tsc -p src/client/tsconfig.json
and the command works fine.
Upvotes: 4
Views: 8376
Reputation: 1275
In my case the problem was caused by the fact that VSCode did not read tasks.json on the fly. I.e. I have to restart VSCode when I change tasks.json. After the restart everything works fine. Here is a similar discussion, they say:
There was a problem that the tasks.json didn't get reparsed after a change if not task has been started before. This is fixed for the next releases. However looks like that people get this even without editing the tasks.json.
The comment was added back in 2017, but it looks like the problem with restart is not fixed yet (I have VSCode 1.32.1).
Upvotes: 9
Reputation: 9558
I just had the reverse problem that @Benjamin Blois reported above, all backward double slashes in paths for typescript tasks within tasks.json had to be replaced now with a forward slash. Fine with me, that's way more readable, doesn't need escaped, etc.
Had:
{ ... "tsconfig": "src\\project-foo\\tsconfig.json" ... }
Changed to:
{ ... "tsconfig": "src/project-foo/tsconfig.json" ... }
Upvotes: 0
Reputation: 61
I'm probably a bit late here, but this might help someone else.
I had the exact same issue, and after some tinkering, I solved the problem by replacing forward slash /
by double backward slashes \\
in the paths.
For instance, replacing
"tsconfig": "src/server/tsconfig.json",
by
"tsconfig": "src\\server\\tsconfig.json",
disclaimer: I only tested that on Windows. Considering that forward slash is the standard for every other platform, this may not work on other platforms :/.
Upvotes: 6