Skip to content

Commit

Permalink
Merge branch 'master' into rjmurillo/WebView/CommunityToolkit#2180
Browse files Browse the repository at this point in the history
  • Loading branch information
nmetulev authored Jul 11, 2018
2 parents 08182c4 + c0b2af2 commit 7d93609
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .vsts-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ steps:
inputs:
versionSpec: 4.6.2

- powershell: .\build\Install-WindowsSdkISO.ps1 17704
displayName: Insider SDK

- task: DotNetCoreCLI@2
inputs:
command: build
Expand Down
3 changes: 3 additions & 0 deletions .vsts-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ steps:
inputs:
versionSpec: 4.6.2

- powershell: .\build\Install-WindowsSdkISO.ps1 17704
displayName: Insider SDK

- powershell: .\build\build.ps1 -target=Package
displayName: Build

Expand Down
121 changes: 121 additions & 0 deletions build/Install-WindowsSdkISO.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Set the URI for the SDK
param([string]$buildNumber)

$uri = "https://go.microsoft.com/fwlink/?prd=11966&pver=1.0&plcid=0x409&clcid=0x409&ar=Flight&sar=Sdsurl&o1=$buildNumber"

if ($env:TEMP -eq $null) {
$env:TEMP = Join-Path $env:SystemDrive 'temp'
}

$winsdkTempDir = Join-Path $env:TEMP "WindowsSDK"

if (![System.IO.Directory]::Exists($winsdkTempDir)) {
[void][System.IO.Directory]::CreateDirectory($winsdkTempDir)
}

$file = "winsdk.iso"

function Download-File {
param (
[string] $outDir,
[string] $downloadUrl,
[string] $downloadName
)
# The ISO file can be large (800 MB), we want to use smart caching if we can to avoid long delays
# Note that some sources explicitly disable caching, so this may not be possible
$etagFile = Join-path $outDir "$downloadName.ETag"
$downloadPath = Join-Path $outDir "$downloadName.download"
$downloadDest = Join-Path $outDir $downloadName
$downloadDestTemp = Join-Path $outDir "$downloadName.tmp"
$headers = @{}

Write-Host -NoNewline "Ensuring that $downloadName is up to date..."

# if the destination folder doesn't exist, delete the ETAG file if it exists
if (!(Test-Path -PathType Container $downloadDest) -and (Test-Path -PathType Container $etagFile)) {
Remove-Item -Force $etagFile
}

if (Test-Path $etagFile) {
$headers.Add("If-None-Match", [System.IO.File]::ReadAllText($etagFile))
}

try {
# Dramatically speeds up download performance
$ProgressPreference = 'SilentlyContinue'
$response = Invoke-WebRequest -Headers $headers -Uri $downloadUrl -PassThru -OutFile $downloadPath -UseBasicParsing
} catch [System.Net.WebException] {
$response = $_.Exception.Response
}

if ($response.StatusCode -eq 200) {
Unblock-File $downloadPath
[System.IO.File]::WriteAllText($etagFile, $response.Headers["ETag"])

$downloadDestTemp = $downloadPath;


# Delete and rename to final dest
if (Test-Path -PathType Container $downloadDest) {
[System.IO.Directory]::Delete($downloadDest, $true)
}

Move-Item -Force $downloadDestTemp $downloadDest
Write-Host "Updated $downloadName"
} elseif ($response.StatusCode -eq 304) {
Write-Host "Done"
} else {
Write-Host
Write-Warning "Failed to fetch updated file from $downloadUrl"
if (!(Test-Path $downloadDest)) {
throw "$downloadName was not found at $downloadDest"
} else {
Write-Warning "$downloadName may be out of date"
}
}

return $downloadDest
}

function Mount-ISO {
param (
[string] $isoPath
)
# Check if image is already mounted
$isoDrive = (Get-DiskImage -ImagePath $isoPath | Get-Volume).DriveLetter

if (!$isoDrive) {
Mount-DiskImage -ImagePath $isoPath -StorageType ISO
}

$isoVolume = (Get-DiskImage -ImagePath $isoPath | Get-Volume)
$isoDrive = $isoVolume.DriveLetter + ":"

Write-Host "$isoPath mounted to $isoDrive"

return $isoDrive
}

function Dismount-ISO {
param (
[string] $isoPath
)
$isoDrive = (Get-DiskImage -ImagePath $isoPath | Get-Volume).DriveLetter
if ($isoDrive) {
Dismount-DiskImage -ImagePath $isoPath
}
}

Write-Output "Getting WinSDK from $uri"
$downloadFile = Download-File $winsdkTempDir $uri $file

# TODO Check if zip, exe, iso, etc.
Write-Output "Mounting ISO $file..."
$isoDrive = Mount-ISO $downloadFile


Write-Host "Installing WinSDK"
$setupPath = Join-Path $isoDrive "WinSDKSetup.exe"
Start-Process -Wait $setupPath "/features OptionId.UWPCpp /q"

Dismount-ISO $downloadFile

0 comments on commit 7d93609

Please sign in to comment.