From 143b00efc7467a1b32e6fafb01a854d2aba8ce6b Mon Sep 17 00:00:00 2001 From: Simone Date: Mon, 11 May 2026 20:47:00 +0200 Subject: [PATCH] perf(template): replace all IWR -OutFile with WebClient.DownloadFile (10 occurrences) --- template/Setup-WinBuild2025.ps1 | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/template/Setup-WinBuild2025.ps1 b/template/Setup-WinBuild2025.ps1 index 5bdb03e..f985e17 100644 --- a/template/Setup-WinBuild2025.ps1 +++ b/template/Setup-WinBuild2025.ps1 @@ -756,8 +756,8 @@ if ($dotnetInstalled) { else { Write-Host "Downloading dotnet-install.ps1..." $dotnetInstallScript = "$env:TEMP\dotnet-install.ps1" - Invoke-WebRequest -Uri 'https://dot.net/v1/dotnet-install.ps1' ` - -OutFile $dotnetInstallScript -UseBasicParsing + (New-Object System.Net.WebClient).DownloadFile( + 'https://dot.net/v1/dotnet-install.ps1', $dotnetInstallScript) Assert-Hash -FilePath $dotnetInstallScript -Label 'dotnet-install.ps1' ` -Expected $script:Hashes['DotNetInstallScript'] @@ -805,7 +805,7 @@ else { $pyInstallerUrl = "https://www.python.org/ftp/python/$PythonVersion/python-$PythonVersion-amd64.exe" $pyInstallerPath = 'C:\CI\python_installer.exe' Write-Host "Downloading Python $PythonVersion installer..." - Invoke-WebRequest -Uri $pyInstallerUrl -OutFile $pyInstallerPath -UseBasicParsing + (New-Object System.Net.WebClient).DownloadFile($pyInstallerUrl, $pyInstallerPath) Assert-Hash -FilePath $pyInstallerPath -Label "python-$PythonVersion-amd64.exe" ` -Expected $script:Hashes['Python'] @@ -861,7 +861,7 @@ else { Write-Host "Downloading VS Build Tools installer..." Remove-Item $vsInstallerPath -ErrorAction SilentlyContinue # remove any stale/corrupt copy - Invoke-WebRequest -Uri $vsInstallerUrl -OutFile $vsInstallerPath -UseBasicParsing + (New-Object System.Net.WebClient).DownloadFile($vsInstallerUrl, $vsInstallerPath) Assert-Hash -FilePath $vsInstallerPath -Label 'vs_buildtools.exe' ` -Expected $script:Hashes['VSBuildToolsBootstrapper'] @@ -1058,7 +1058,7 @@ if (Test-Path $gitExe) { Write-Host "Downloading Git for Windows $GitVersion..." try { - Invoke-WebRequest -Uri $gitUrl -OutFile $gitInstaller -UseBasicParsing + (New-Object System.Net.WebClient).DownloadFile($gitUrl, $gitInstaller) } catch { throw "Failed to download Git from $gitUrl : $_" } @@ -1109,7 +1109,7 @@ if (Test-Path $sevenZipExe) { Write-Host "Downloading 7-Zip $SevenZipVersion..." try { - Invoke-WebRequest -Uri $sevenZipUrl -OutFile $sevenZipMsi -UseBasicParsing + (New-Object System.Net.WebClient).DownloadFile($sevenZipUrl, $sevenZipMsi) } catch { throw "Failed to download 7-Zip from $sevenZipUrl : $_" } @@ -1159,7 +1159,7 @@ if (Test-Path $pwsh7Exe) { $pwsh7Url = "https://github.com/PowerShell/PowerShell/releases/download/v$Pwsh7Version/PowerShell-$Pwsh7Version-win-x64.msi" $pwsh7Msi = 'C:\CI\pwsh_installer.msi' Write-Host "Downloading PowerShell $Pwsh7Version from GitHub releases..." - try { Invoke-WebRequest -Uri $pwsh7Url -OutFile $pwsh7Msi -UseBasicParsing } + try { (New-Object System.Net.WebClient).DownloadFile($pwsh7Url, $pwsh7Msi) } catch { throw "Failed to download PowerShell from '$pwsh7Url': $_" } Assert-Hash -FilePath $pwsh7Msi -Label "PowerShell-$Pwsh7Version-win-x64.msi" ` -Expected $script:Hashes['Pwsh7'] @@ -1265,7 +1265,7 @@ if (Test-Path $ghExe) { $ghUrl = "https://github.com/cli/cli/releases/download/v$GhCliVersion/gh_${GhCliVersion}_windows_amd64.msi" $ghMsi = 'C:\CI\ghcli_installer.msi' Write-Host "Downloading GitHub CLI $GhCliVersion from GitHub releases..." - try { Invoke-WebRequest -Uri $ghUrl -OutFile $ghMsi -UseBasicParsing } + try { (New-Object System.Net.WebClient).DownloadFile($ghUrl, $ghMsi) } catch { throw "Failed to download GitHub CLI from '$ghUrl': $_" } Assert-Hash -FilePath $ghMsi -Label "gh_${GhCliVersion}_windows_amd64.msi" ` -Expected $script:Hashes['GhCli'] @@ -1316,7 +1316,7 @@ if (Test-Path $cmakeExe) { $cmakeUrl = "https://github.com/Kitware/CMake/releases/download/v$CMakeVersion/cmake-$CMakeVersion-windows-x86_64.msi" $cmakeMsi = 'C:\CI\cmake_installer.msi' Write-Host "Downloading CMake $CMakeVersion from GitHub releases..." - try { Invoke-WebRequest -Uri $cmakeUrl -OutFile $cmakeMsi -UseBasicParsing } + try { (New-Object System.Net.WebClient).DownloadFile($cmakeUrl, $cmakeMsi) } catch { throw "Failed to download CMake from '$cmakeUrl': $_" } Assert-Hash -FilePath $cmakeMsi -Label "cmake-$CMakeVersion-windows-x86_64.msi" ` -Expected $script:Hashes['CMake'] @@ -1353,7 +1353,7 @@ if (Test-Path $nodeExe) { $nodeUrl = "https://nodejs.org/dist/v$NodeJSVersion/node-v$NodeJSVersion-x64.msi" $nodeMsi = 'C:\CI\nodejs_installer.msi' Write-Host "Downloading Node.js $NodeJSVersion from nodejs.org..." - try { Invoke-WebRequest -Uri $nodeUrl -OutFile $nodeMsi -UseBasicParsing } + try { (New-Object System.Net.WebClient).DownloadFile($nodeUrl, $nodeMsi) } catch { throw "Failed to download Node.js from '$nodeUrl': $_" } Assert-Hash -FilePath $nodeMsi -Label "node-v$NodeJSVersion-x64.msi" ` -Expected $script:Hashes['NodeJS'] @@ -1425,7 +1425,7 @@ if ((Test-Path $sysDir) -and (Test-Path $sysPsExec)) { $sysZipUrl = 'https://download.sysinternals.com/files/SysinternalsSuite.zip' $sysZip = 'C:\CI\sysinternals.zip' Write-Host "Downloading Sysinternals Suite from Microsoft CDN..." - try { Invoke-WebRequest -Uri $sysZipUrl -OutFile $sysZip -UseBasicParsing } + try { (New-Object System.Net.WebClient).DownloadFile($sysZipUrl, $sysZip) } catch { throw "Failed to download Sysinternals Suite: $_" } if (-not (Test-Path $sysDir)) { New-Item -ItemType Directory -Path $sysDir -Force | Out-Null