parameters:
  pool: 'vs2017-win2016'
  jobName: 'win_build'
  displayName: Windows Build

jobs:
- job: ${{ parameters.jobName }}
  pool:
    vmImage: ${{ parameters.pool }}

  displayName: ${{ parameters.displayName }}

  steps:
  - powershell: |
      Get-ChildItem -Path env:
    displayName: Capture Environment
    condition: succeededOrFailed()

  - powershell:  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')

  - ${{ if ne(variables['AzDevOpsFeed'], '') }}:
    - template: /tools/releaseBuild/azureDevOps/templates/insert-nuget-config-azfeed.yml

  - pwsh: |
      if (Test-Path -Path $HOME/.dotnet) {
          Remove-Item $HOME/.dotnet -Recurse -Force
      }
    displayName: Remove Old .NET SDKs
    condition: succeededOrFailed()

  - pwsh: |
      Import-Module .\tools\ci.psm1
      Invoke-CIInstall -SkipUser
    displayName: Bootstrap
    condition: succeeded()

  - powershell: |
      Import-Module .\tools\ci.psm1
      Invoke-CIBuild
    displayName: Build
    condition: succeeded()

  - powershell: |
      Import-Module .\tools\ci.psm1
      Restore-PSOptions
      Invoke-CIxUnit -SkipFailing
    displayName: xUnit Tests
    condition: succeeded()
    continueOnError: true
