title: Is there a way to dynamically assign names to tasks in yaml pipelines for Azure Devops?
body: <p>I am using the DownloadPipelineArtifact@2 task and looping over an array of pipelines to download the artifacts for each of them. I would like to use the $(BuildNumber) output of each of these tasks in subsequent tasks.</p>
  <pre><code>${{ each p in pipelines }}:
    - task: DownloadPipelineArtifact@2
      displayName: 'Download ${{ p.alias }} Artifact - ${{ p.artifact }}'
      name: 'Download_${{ p.alias }}'
      inputs:
        buildType: specific
        project: $(System.TeamProjectId)
        pipeline: ${{ p.id }}
        preferTriggeringPipeline: false
        runVersion: latestFromBranch
        runBranch: 'refs/heads/${{ p.branch }}'
        artifact: ${{ p.artifact }}
        patterns: ${{ p.patterns }}
        targetPath: '$(Pipeline.Workspace)/artifacts/${{ p.alias }}/${{ p.artifact }}'
  </code></pre>
  <p>Unfortunately, I am unable to do so as I would need to refer to the task by it's name and I am not able to assign dynamic names to the tasks. I get an error saying</p>
  <blockquote>
  <p>Valid names may only contain alphanumeric characters and '_' and may not start with a number.</p>
  </blockquote>
  <p>I tried using runtime variables, expressions and a counter for the name but all fail with the same error. I am assuming here the name field is not dynamically assignable.</p>
  <p>All works well without the name field. But from what I understand I would need the name of the task to refer to it and extract it's output. Something like:</p>
  <p><code>{{ taskName.BuildNumber }}</code></p>
  <p>If anyone knows of any way in which I can assign the name dynamically or through which I can extract the $(BuildNumber) for each task in the loop, please let me know. Thanks!</p>