# This Yaml Document has been converted by ESAI Yaml Pipeline Conversion Tool.
parameters:
- name: layoutRoot
  type: string
- name: flavor
  type: string

steps:

# Package .NET Core Windows dependency (VC++ Redistributable)
- powershell: |
    Write-Host "Downloading 'VC++ Redistributable' package."
    $outDir = Join-Path -Path $env:TMP -ChildPath ([Guid]::NewGuid())
    New-Item -Path $outDir -ItemType directory 
    $outFile = Join-Path -Path $outDir -ChildPath "ucrt.zip"
    Invoke-WebRequest -Uri https://vstsagenttools.blob.core.windows.net/tools/ucrt/ucrt_${{ parameters.flavor }}.zip -OutFile $outFile
    Write-Host "Unzipping 'VC++ Redistributable' package to agent layout."
    $unzipDir = Join-Path -Path $outDir -ChildPath "unzip"
    Add-Type -AssemblyName System.IO.Compression.FileSystem
    [System.IO.Compression.ZipFile]::ExtractToDirectory($outFile, $unzipDir)
    $agentLayoutBin = Join-Path -Path $(Build.SourcesDirectory) -ChildPath "${{ parameters.layoutRoot }}\bin"
    Copy-Item -Path $unzipDir -Destination $agentLayoutBin -Force
  displayName: Package UCRT