-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetDXC.ps1
More file actions
33 lines (29 loc) · 1022 Bytes
/
Copy pathGetDXC.ps1
File metadata and controls
33 lines (29 loc) · 1022 Bytes
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
$SaveFolder = $args[0]
if ($args.count -lt 1)
{
Write-Host "Missing save folder parameter"
}
if (Test-Path $SaveFolder\*) {
Write-Host "Target Path is not empty. Delete it to redownload the latest DXC"
exit 0
}
New-Item -ItemType Directory -Force -Path $SaveFolder
$JSONURL = "https://api.github.com/repos/microsoft/DirectXShaderCompiler/releases/latest"
$JSON = Invoke-WebRequest -UseBasicParsing -Uri $JSONURL
$ParsedJSON = ConvertFrom-Json -InputObject $JSON
$Assets = Select-Object -InputObject $ParsedJSON -ExpandProperty assets
Foreach ($Asset IN $Assets)
{
if ($Asset.name -match 'dxc.*.zip')
{
$DownloadURL = $Asset.browser_download_url
$ZIPPath = Join-Path -Path $SaveFolder -ChildPath "dxc.zip"
Invoke-WebRequest -UseBasicParsing -Uri $DownloadURL -OutFile $ZIPPath
Expand-Archive -Path $ZIPPath -DestinationPath $SaveFolder -Force
Remove-Item -Path $ZIPPath
Write-Host "Sucessfully downloaded DXC $($Asset.name)"
exit 0
}
}
Write-Host "Something went wrong, couldn't download DXC"
exit 1