summaryrefslogtreecommitdiff
path: root/xmake/scripts/download.ps1
blob: c199836996ed263ce65f7a67c26cbb3bb0f15086 (plain)
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
#!/usr/bin/env pwsh
#Requires -version 5

param (
    [string]$url,
    [string]$outputfile
)

& {
    function writeErrorTip($msg) {
        Write-Host $msg -BackgroundColor Red -ForegroundColor White
    }

    $temppath = ([System.IO.Path]::GetTempPath(), $env:TMP, $env:TEMP, "$(Get-Location)" -ne $null)[0]
    [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"

    function download {
        try {
            Invoke-Webrequest $url -OutFile $outputfile -UseBasicParsing
        } catch {
            writeErrorTip 'Download failed!'
            throw
        }
    }

    download
}