title: Dynamically set Azure DevOps variable in scripts
body: <p>I have <em>n</em> number of variables that I need to assign as Azure DevOps variables in a Release pipeline, and it doesn't seem like I'm getting the syntax right. </p>
  
  <p>The variables may have different values (variable names) such that they could be: 
  - {guid 1}
  - {guid 2}
  ...</p>
  
  <p>So I won't know them prior to runtime. The problem is that it seems all of the examples of vso[task.setvariable] use static variable names, but I need to set it dynamically. </p>
  
  <p>Here's what should work but doesn't: </p>
  
  <pre><code> Write-Host "##vso[task.setvariable variable=$($myVariable)]$($myValue)"
  </code></pre>
  
  <p>I've also tried just using [Environment]::SetEnvironmentVariable (with user) and it doesn't seem to persist across two different tasks in the same job. </p>
  
  <pre><code>[Environment]::SetEnvironmentVariable($myVariable, $myValue, 'User')
  </code></pre>
  
  <p>(Is null in subsequent task)</p>
  
  <p>Is there some way that I can dynamically create release variables that persist between tasks? I've tried to search and found one question on the developer community but no answer to it. </p>