Hello Sándor Deák,
Welcome to Microsoft Q&A forum.
As we can see from this document,
${file}: The arguments for this task include a macro that retrieves the file currently selected in Solution Explorer
If you have set the active startup item(.exe file), it could be detected as the currently selected file in Solution Explorer when building. I would suggest you can set appliesTo
property in tasks.vs.json
file to limit the scope of ${file} to .cpp
files.
For example
{
"version": "0.2.1",
"tasks": [
{
"taskName": "Echo filename",
"appliesTo": "*.cpp",
"type": "default",
"command": "${env.COMSPEC}",
"args": [
"echo ${file}"
]
}
]
}
Best Regards,
Dou
If the answer is helpful, please click "Accept Answer" and upvote it. Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.