replace builtin install method with web request to app installer

This commit is contained in:
Baipyrus 2024-11-25 11:23:03 +01:00
parent 24b6d1f115
commit 4ce997d016

View File

@ -1,12 +1,18 @@
function InstallWinget function InstallWinget
{ {
# Reference: https://learn.microsoft.com/en-us/windows/package-manager/winget/#install-winget-on-windows-sandbox $download = 'https://api.github.com/repos/microsoft/winget-cli/releases/latest'
$progressPreference = 'silentlyContinue' $setup = "$env:TMP\winget_setup.msixbundle"
Write-Host "Installing WinGet PowerShell module from PSGallery..."
Install-PackageProvider -Name NuGet -Force | Out-Null if (-not (Test-Path $setup))
Install-Module -Name Microsoft.WinGet.Client -Force -Repository PSGallery | Out-Null {
Write-Host "Using Repair-WinGetPackageManager cmdlet to bootstrap WinGet..." $releases = Invoke-RestMethod $download
Repair-WinGetPackageManager $assets = $releases | Select-Object -ExpandProperty "assets"
$installer = $assets | Where-Object "name" -Match "msixbundle"
$url = $installer | Select-Object -ExpandProperty "browser_download_url"
Invoke-RestMethod $url -OutFile $setup
}
Add-AppxPackage -Path $setup
} }
function WingetInstall function WingetInstall