I need to create the following json structure and include it with my .NET application using Azure Pipelines and it is not clear to me how to do so.
{
"buildNumber":"$(Build.BuildNumber)",
"buildId":"$(Build.BuildId)",
"branchName":"$(Build.SourceBranchName)",
"commitHash":"$(Build.SourceVersion)"
}
I've tried simply doing a command line to echo the information into a file but I'm not sure of the path necessary to have it picked up by the publish step.
Right now I am experimenting with a powershell task:
    - task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: |
      # Write your PowerShell commands here.
      new-item -itemtype file -path $(Build.SourcesDirectory)/MyFirstExperiment -name "buildinfo.json" -force -value '{
      \"buildNumber\":\"$(Build.BuildNumber)\",
      \"buildId\":\"$(Build.BuildId)\",
      \"branchName\":\"$(Build.SourceBranchName)\",
      \"commitHash\":\"$(Build.SourceVersion)\"
      }'
I see output during the task that the file is created but I must still be missing something obvious because it is not showing up in the build / publish later in the pipeline.
What should I be checking?
I strongly suspect that I am missing something very obvious because there is not a lot of results doing google searches for 'azure pipeline create file'
Thank you in advance!
 
     
    