Test 2024 02 03 (#1583)

* Compile Winutil

* winget fixes and checks

* Compile Winutil

* fix Parsec winget id (#1558)

* Compile Winutil

* fix winget issues

* Compile Winutil

* cleanup winget

* Compile Winutil

* Updated README.md (#1570)

Fixed typos in readme file ("cusom" -> "custom", "twekas" -. "tweaks". Also added full stops.

* Compile Winutil

* Create close-old-issues.yml

* Compile Winutil

* update issues

---------

Co-authored-by: ChrisTitusTech <ChrisTitusTech@users.noreply.github.com>
Co-authored-by: Saikrishnan K <53394202+K-Saikrishnan@users.noreply.github.com>
Co-authored-by: Harry Perkin <68484588+HarryPerkin@users.noreply.github.com>
This commit is contained in:
Chris Titus
2024-02-06 14:02:58 -06:00
committed by GitHub
parent b7a86dea4d
commit d0aa396c2a
8 changed files with 192 additions and 27 deletions

View File

@ -30,7 +30,7 @@ Function Install-WinUtilProgramWinget {
Write-Progress -Activity "$manage Applications" -Status "$manage $Program $($x + 1) of $count" -PercentComplete $($x/$count*100)
if($manage -eq "Installing"){
Start-Process -FilePath winget -ArgumentList "install -e --accept-source-agreements --accept-package-agreements --scope=machine --silent $Program" -NoNewWindow -Wait
Start-Process -FilePath winget -ArgumentList "install -e --accept-source-agreements --accept-package-agreements --ignore-security-hash --disable-interactivity --silent $Program" -NoNewWindow -Wait
}
if($manage -eq "Uninstalling"){
Start-Process -FilePath winget -ArgumentList "uninstall -e --purge --force --silent $Program" -NoNewWindow -Wait

View File

@ -22,6 +22,7 @@ function Install-WinUtilWinget {
if (Test-WinUtilPackageManager -winget) {
# Checks if winget executable exists and if the Windows Version is 1809 or higher
Write-Host "Winget Already Installed"
Start-Process -Verb runas -FilePath powershell.exe -ArgumentList "winget settings --enable InstallerHashOverride" -Wait -NoNewWindow
return
}
@ -39,10 +40,47 @@ function Install-WinUtilWinget {
return
}
Write-Host "Running Alternative Installer and Direct Installing"
Start-Process -Verb runas -FilePath powershell.exe -ArgumentList "choco install winget"
Write-Host "Winget Installed"
Write-Host "Running Alternative Installers and Direct Installing"
Write-Host "- Attempting first install method..."
$wingetURL = "https://github.com/microsoft/winget-cli/releases/latest/download/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
$wingetFileName = Split-Path $wingetURL -Leaf
$wingetInstallerPath = Join-Path $env:TEMP $wingetFileName
Invoke-WebRequest -Uri $wingetURL -OutFile $wingetInstallerPath
Add-AppxPackage -Path $wingetInstallerPath
if (Test-WinUtilPackageManager -winget) {
# Checks if winget executable exists and if the Windows Version is 1809 or higher
Write-Host "Winget Installed via GitHub"
return
} else {
Write-Host "- Failed to install Winget via GitHub"
}
# Second Method
Write-Host "- Attempting second install method..."
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
Install-Script -Name winget-install -Force
$wingetArgument = "-ExecutionPolicy Bypass winget-install.ps1"
Start-Process powershell -ArgumentList $wingetArgument -Wait
if (Test-WinUtilPackageManager -winget) {
# Checks if winget executable exists and if the Windows Version is 1809 or higher
Write-Host "Winget Installed via PowerShell Gallery Script"
return
} else {
Write-Host "- Failed to install Winget via PowerShell Gallery Script"
}
# Third Method
Write-Host "- Attempting third install method..."
Start-Process -Verb runas -FilePath powershell.exe -ArgumentList "choco install winget --force" -Wait -NoNewWindow
if (Test-WinUtilPackageManager -winget) {
# Checks if winget executable exists and if the Windows Version is 1809 or higher
Write-Host "Winget Installed via Chocolatey"
return
} else {
Write-Host "- Failed to install Winget via Chocolatey"
}
}
Catch{
throw [WingetFailedInstall]::new('Failed to install')

View File

@ -17,14 +17,34 @@ function Test-WinUtilPackageManager {
[System.Management.Automation.SwitchParameter]$choco
)
if($winget){
if (Test-Path ~\AppData\Local\Microsoft\WindowsApps\winget.exe) {
# Install Winget if not detected
$wingetExists = Get-Command -Name winget -ErrorAction SilentlyContinue
if ($wingetExists) {
$wingetVersion = [System.Version]::Parse((winget --version).Trim('v'))
$minimumWingetVersion = [System.Version]::new(1,2,10691) # Win 11 23H2 comes with bad winget v1.2.10691
$wingetOutdated = $wingetVersion -le $minimumWingetVersion
Write-Host "Winget v$wingetVersion"
}
if (!$wingetExists -or $wingetOutdated) {
if (!$wingetExists) {
Write-Host "Winget not detected"
} else {
Write-Host "- Winget out-dated"
}
}
if ($winget) {
if ($wingetExists -and !$wingetOutdated) {
Write-Host "- Winget up-to-date"
return $true
}
}
if($choco){
if ((Get-Command -Name choco -ErrorAction Ignore) -and ($chocoVersion = (Get-Item "$env:ChocolateyInstall\choco.exe" -ErrorAction Ignore).VersionInfo.ProductVersion)){
Write-Host "Chocolatey v$chocoVersion"
return $true
}
}