-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGet-WindowsAppSdk.ps1
34 lines (32 loc) · 1.35 KB
/
Get-WindowsAppSdk.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Usage: Get-WindowsAppSdk.ps1 -arch <x64|arm64>
param (
[ValidateSet("x64", "arm64")]
[Parameter(Mandatory = $true)]
[string] $arch
)
function Download-File([string] $url, [string] $outputPath, [string] $etagFile) {
Write-Host "Downloading '$url' to '$outputPath'"
# We use `curl.exe` here because `Invoke-WebRequest` is notoriously slow.
& curl.exe `
--progress-bar `
-v `
--show-error `
--fail `
--location `
--etag-compare $etagFile `
--etag-save $etagFile `
--output $outputPath `
$url
if ($LASTEXITCODE -ne 0) { throw "Failed to download $url" }
if (!(Test-Path $outputPath) -or (Get-Item $outputPath).Length -eq 0) {
throw "Failed to download '$url', output file '$outputPath' is missing or empty"
}
}
# Download the Windows App Sdk binary from Microsoft for this platform if we don't have
# it yet (or it's different).
$windowsAppSdkMajorVersion = "1.6"
$windowsAppSdkFullVersion = "1.6.250228001"
$windowsAppSdkPath = Join-Path $PSScriptRoot "files\windows-app-sdk-$($arch).exe"
$windowsAppSdkUri = "https://aka.ms/windowsappsdk/$($windowsAppSdkMajorVersion)/$($windowsAppSdkFullVersion)/windowsappruntimeinstall-$($arch).exe"
$windowsAppSdkEtagFile = $windowsAppSdkPath + ".etag"
Download-File $windowsAppSdkUri $windowsAppSdkPath $windowsAppSdkEtagFile