How to pass variables between build/deploy tasks in a TaskGroup in VSTS 16.131.28601.4
I'm not sure my approach is any "better". However, what I have done in the past was to use Table Storage or Cosmos DB to store the key-value pairs that needed to be persisted between each stage.

The general schema was:


Key: buildNum-variableName 
Value: variableValue


I then created various wrappers for the SDK to access from PowerShell and MSBuild, this also enabled chaining multiple builds together to create a CI/CD pipeline.