I have tried to use v2 of the cmd task for a few different scenarios, and my usage has led me to believe that only the first command in the script runs.
Example, here is my script/command in the task:
npm install -g tfx-cli
tfx login --service-url $(TfsUrl) --auth-type pat --token $(TfsPAT)
tfx build tasks upload --task-path $(taskFolderName) --overwrite
Based on the logs, it is only running the first command. I just get an output that the package was installed. Is that intended? The way the task and documentation is laid out, it seems like it should run the entire script / multiple commands. This is the default content in the task when you add it - note 'commands' :
echo Write your commands here
echo Hello world
Instead, I can just use 3 command line tasks which is no problem, but it would be helpful to document if this is a known issue / if this is the intent of the task.
Thanks!
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
On Windows, npm is a .cmd script. Windows CMD does something strange with .cmd files - I think it exits the current session and starts a new one (or similar - I'm honestly a bit fuzzy on the details). The upshot is: when you enter commands interactively, you can't see this difference, but when running headless on a CI machine, the difference matters. You need to use the call command for npm or npm globals.
call npm install -g tfx-cli
call tfx login --service-url $(TfsUrl) --auth-type pat --token $(TfsPAT)
call tfx build tasks upload --task-path $(taskFolderName) --overwrite
You're not the first to be confused by this; I'll add a note in the docs. Thank you!
@vtbassmatt Thank you for the clarification!
Most helpful comment
On Windows,
npmis a .cmd script. Windows CMD does something strange with .cmd files - I think it exits the current session and starts a new one (or similar - I'm honestly a bit fuzzy on the details). The upshot is: when you enter commands interactively, you can't see this difference, but when running headless on a CI machine, the difference matters. You need to use thecallcommand fornpmor npm globals.You're not the first to be confused by this; I'll add a note in the docs. Thank you!