Is it possible to set an VSTS Build variable in a Build Step so that the value can be used in a subsequent Build Step?

When inside of a script you can update a variable by emitting the following in your ps1

"##vso[task.setvariable variable=testvar;]testvalue"

You can then pass the variable into the next script using $(testvar)


This doc from the API talks about what ##vso commands you can use.

Don't forget to set system.debug to true. It seems there is a bug that muted stdout and thus, all ##vso are not working.

https://github.com/Microsoft/vso-agent-tasks/blob/master/docs/authoring/commands.md