mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-01-03 11:34:54 -06:00
8c91bfca2d
- Removed Get-LatestHash from Install-WinUtilWinget.ps1, replaced by Get-WinUtilWingetLatest.ps1. - Added new Winget Install method in case of choco failing to install. Environment refresh line included. - Get-WinUtilWingetPrerequisites added: Downloads the prerequisites required for the latest version of Winget. - Get-WinUtilWingetLatest added: Uses the GitHub API to find the latest version of Winget and download it along with the accompanied License1.xml file. Fixes: - Removed --scope=machine from winget install command in Install-WinUtilProgramWinget. Non-UWP Apps fail to install if scope is set to machine. Error code: 0x80070005. More information commented in file.
24 lines
1.3 KiB
PowerShell
24 lines
1.3 KiB
PowerShell
function Get-WinUtilWingetLatest {
|
|
<#
|
|
.SYNOPSIS
|
|
Uses GitHub API to check for the latest release of Winget.
|
|
.DESCRIPTION
|
|
This function grabs the latest version of Winget and returns the download path to Install-WinUtilWinget for installation.
|
|
#>
|
|
|
|
Try{
|
|
# Grabs the latest release of Winget from the Github API for the install process.
|
|
$response = Invoke-RestMethod -Uri "https://api.github.com/repos/microsoft/Winget-cli/releases/latest" -Method Get -ErrorAction Stop
|
|
$latestVersion = $response.tag_name #Stores version number of latest release.
|
|
$licenseWingetUrl = $response.assets.browser_download_url[0] #Index value for License file.
|
|
Write-Host "Latest Version:`t$($latestVersion)`n"
|
|
$assetUrl = $response.assets.browser_download_url[2] #Index value for download URL.
|
|
Invoke-WebRequest -Uri $licenseWingetUrl -OutFile $ENV:TEMP\License1.xml
|
|
# The only pain is that the msixbundle for winget-cli is 246MB. In some situations this can take a bit, with slower connections.
|
|
Invoke-WebRequest -Uri $assetUrl -OutFile $ENV:TEMP\Microsoft.DesktopAppInstaller.msixbundle
|
|
}
|
|
Catch{
|
|
throw [WingetFailedInstall]::new('Failed to get latest Winget release and license')
|
|
}
|
|
}
|