Change:
} } <del> if ((ContributedTask.is(task) || CustomTask.is(task)) && (task.command)) { return Promise.all(promises).then((summaries): Promise<ITaskSummary> | ITaskSummary => { for (const summary of summaries) { if (summary.exitCode !== 0) { this._removeInstances(task); return { exitCode: summary.exitCode }; } </del> <ins> return Promise.all(promises).then((summaries): Promise<ITaskSummary> | ITaskSummary => { for (const summary of summaries) { if (summary.exitCode !== 0) { return { exitCode: summary.exitCode }; </ins> } <ins> } if ((ContributedTask.is(task) || CustomTask.is(task)) && (task.command)) { </ins> if (this._isRerun) { return this._reexecuteCommand(task, trigger, alreadyResolved!); } else { return this._executeCommand(task, trigger, alreadyResolved!); } <del> }); } else { return Promise.all(promises).then((summaries): ITaskSummary => { for (const summary of summaries) { if (summary.exitCode !== 0) { return { exitCode: summary.exitCode }; } } return { exitCode: 0 }; }); } </del> <ins> } return { exitCode: 0 }; }); </ins> }).finally(() => { if (this._activeTasks[mapKey] === activeTask) { delete this._activeTasks[mapKey]; } }); <del> const activeTask = { task, promise }; </del> <ins> const lastInstance = this._getInstances(task).pop(); const count = lastInstance?.count ?? { count: 0 }; count.count++; const activeTask = { task, promise, count }; </ins> this._activeTasks[mapKey] = activeTask; return promise; }

Discussion:
<!-- Do Not Delete This! bugreporttemplate --<!-- Please read our Rules of Conduct: --<!-- Read our guide about submitting issues: --<!-- Search existing issues to avoid creating duplicates. --<!-- Test using the latest Insiders build to see if your issue has already been fixed: --<!-- Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. --<!-- Launch with to check. --Does this issue occur when all extensions are disabled?: Yes <!-- If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. --<!-- Issues caused by an extension need to be reported directly to the extension publisher. The 'Help Report Issue' dialog can assist with this. --- VS Code Version: 1.78.0 and older and (with slightly different behavior) insiders as of 5/4/2023 OS Version: MacOS 13.3.1 (a) Steps to Reproduce: Use these commands to produce and launch a suitable project: First bug: in either 1.78.0 or the nightly, use to launch , then hit Cmd-Shift-B to launch . You end up with two copies of running, when it should have an implicit of 1. Hit Cmd-Shift-B again, and it will tell you you've hit the instance limit. The problem here is that dependent tasks don't count towards the instance limit. Second bug: Now add to , and repeat the above. There is no change in the nightly (as you might expect), but surprisingly 1.78.0 now reports that it can't start a second copy. But thats just a bug; if you change it to and repeat, 1.78.0, still tells you it can't launch a second copy. This bug was fixed by , so I'm just including it for completeness. Third bug: Add to . Now hit Cmd-Shift-B to launch , then use to launch . will (correctly) re-use the already running task, rather than launching a new one. Now kill all the terminals (to make the next step less confusing). Hit Cmd-Shift-B to launch sleeper, wait 5 seconds, and hit Cmd-Shift-B again, wait another 5 seconds for the first task to finish, and then run .

Now, although the second task is still running, starts a new one. The issue here is that when looking for an existing dependent task, uses the task's , which only matches the first instance of a task with greater than 1 (and here, that task has already finished).