Skip to content

Instantly share code, notes, and snippets.

@blinds52
Forked from KaiWalter/downloadWebHostSource.PS1
Created November 16, 2019 22:45
Show Gist options
  • Save blinds52/f942e3a1a73ec87acc421c9910774a57 to your computer and use it in GitHub Desktop.
Save blinds52/f942e3a1a73ec87acc421c9910774a57 to your computer and use it in GitHub Desktop.
download Azure Functions WebHost source code
param(
[string]$DownloadBuildNumber
)
$url = "https://github.com/Azure/azure-functions-host/archive/" + $DownloadBuildNumber + ".zip"
$url2 = "https://github.com/Azure/azure-functions-host/archive/v" + $DownloadBuildNumber + ".zip"
$targetZip = Join-Path $PSScriptRoot "WebHost.zip"
if (Test-Path $targetZip) {
Remove-Item $targetZip -Force
}
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
try {
Write-Host "Downloading" $url
(New-Object Net.WebClient).DownloadFile($url, $targetZip)
}
catch {
Write-Host "not found on URL" $url
}
if (!(Test-Path $targetZip)) {
try {
Write-Host "Downloading" $url2
(New-Object Net.WebClient).DownloadFile($url2, $targetZip)
}
catch {
Write-Host "not found on URL" $url2
}
}
if (Test-Path $targetZip) {
Expand-Archive $targetZip
Remove-Item $targetZip
$sources = (Get-ChildItem azure-functions-host* -Recurse -Directory)[0]
Move-Item $sources Sources
}
else {
Write-Host "##vso[task.logissue type=error;] URL error"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment