parameters:
  pwsh: true

steps:
  - powershell: |
      Write-Host "Installing PowerShell Daily..."

      # Use `AGENT_TEMPDIRECTORY` to make sure the downloaded PowerShell is cleaned up.
      $powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell'
      Invoke-WebRequest -Uri https://aka.ms/install-powershell.ps1 -OutFile ./install-powershell.ps1

      ./install-powershell.ps1 -Destination $powerShellPath -Daily

      # Using `prependpath` to update the PATH just for this build.
      Write-Host "##vso[task.prependpath]$powerShellPath"
    displayName: Install PowerShell Daily
    continueOnError: true

  - pwsh: '$PSVersionTable'
    displayName: Display PowerShell version information

  - pwsh: Write-Host "##vso[build.updatebuildnumber]$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhmmss"))"
    displayName: Set Build Name for Non-PR
    condition: ne(variables['Build.Reason'], 'PullRequest')

  - task: PowerShell@2
    inputs:
      filePath: tools/azurePipelinesBuild.ps1
      pwsh: ${{ parameters.pwsh }}

  - publish: module
    artifact: PowerShellEditorServices-Build-$(System.JobId)
    displayName: Publish unsigned pipeline artifacts
    condition: succeededOrFailed()

  - task: PublishTestResults@2
    inputs:
      testRunner: VSTest
      testResultsFiles: '**/*.trx'
    condition: succeededOrFailed()

  - task: PublishTestResults@2
    inputs:
      testRunner: NUnit
      testResultsFiles: '**/TestResults.xml'
    condition: succeededOrFailed()

parameters:
  pwsh: true

steps:
  - pwsh: '$PSVersionTable'
    displayName: Display PowerShell version information

  - pwsh: Write-Host "##vso[build.updatebuildnumber]$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhmmss"))"
    displayName: Set Build Name for Non-PR
    condition: ne(variables['Build.Reason'], 'PullRequest')

  - task: PowerShell@2
    inputs:
      filePath: tools/azurePipelinesBuild.ps1
      pwsh: ${{ parameters.pwsh }}

  - publish: module
    artifact: PowerShellEditorServices-Build-$(System.JobId)
    displayName: Publish unsigned pipeline artifacts
    condition: succeededOrFailed()

  - task: PublishTestResults@2
    inputs:
      testRunner: VSTest
      testResultsFiles: '**/*.trx'
    condition: succeededOrFailed()

  - task: PublishTestResults@2
    inputs:
      testRunner: NUnit
      testResultsFiles: '**/TestResults.xml'
    condition: succeededOrFailed()

Stop using PowerShell daily for CI
Stop using PowerShell daily for CI

It leads to bugs I cannot solve.
