-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade when installer type changes #1640
Comments
In this scenario, the previous installer was a .exe installer and the new version is an MSI. For this scenario, we may need to add a new key to the manifest to indicate what has happened at the transition. Maybe we should uninstall the previous version and install the new MSI version. More examples would help to determine if this is the correct behavior, or if we're going to need to support additional behaviors in the client. I believe in this case you may be able to:
|
An uninstall of the prior exe version was required to allow install of the new msi version. Running the new msi version indicated the uninstall requirement. |
@MagicFirefly, I'm not sure about what the code path would do today. It's worth trying to add the upgrade behavior as "uninstallPrevious" for the new MSI version of the package. winget-cli/schemas/JSON/manifests/v1.0.0/manifest.installer.1.0.0.json Lines 150 to 155 in 17fc527
|
I experienced this issue today with Microsoft Edge. Log is attached
|
I experienced the same. I commented here: microsoft/winget-pkgs#36499 (comment) Got redirected to this existing issue: #752. Found out that a workaround for now is to just use Click to expand#Requires -RunAsAdministrator
#Requires -Version 5.1
<#
.SYNOPSIS
Use winget to update some packages.
.NOTES
Author: Olav Rønnestad Birkeland
Created: 211205
Modified: 211206
.EXAMPLE
& $psISE.CurrentFile.FullPath
#>
# Inpit parameters
[OutputType($null)]
Param()
# PowerShell preferences
$ErrorActionPreference = 'Stop'
$InformationPreference = 'Continue'
# Encoding
$PSDefaultParameterValues['*:Encoding'] = 'utf8'
[Console]::InputEncoding = [Console]::OutputEncoding = $OutputEncoding = [System.Text.Utf8Encoding]::new()
# Assets
## Control what apps to update with winget
### Device/ system context
$Apps = [string[]](
'CodecGuide.K-LiteCodecPack.Mega',
'Eraser.Eraser', # "winget upgrade" does not work, must use "winget install".
'Jabra.Direct',
'Logitech.Options',
'Microsoft.dotnetRuntime.3-x64',
'Microsoft.PowerToys', # "winget upgrade" does not work, must use "winget install".
'Nlitesoft.NTLite',
'Notepad++.Notepad++',
'Plex.Plex', # Not totally silent, "updating" prompt, and starts after install.
'Postman.Postman',
'SoftDeluxe.FreeDownloadManager',
'XnSoft.XnConvert',
'XnSoft.XnViewMP'
)
### User context, only if not running as SYSTEM
if ([System.Security.Principal.WindowsIdentity]::GetCurrent().'User'.'Value' -ne 'S-1-5-18') {
$Apps += [string[]](
'GitHub.GitHubDesktop',
'OpenWhisperSystems.Signal'
)
}
## Path of winget-cli
$WingetCliPath = [string](
$(
if ([System.Security.Principal.WindowsIdentity]::GetCurrent().'User'.'Value' -eq 'S-1-5-18') {
'{0}\AppInstallerCLI.exe' -f (
(Get-Item -Path ('{0}\WindowsApps\Microsoft.DesktopAppInstaller_*_x64__8wekyb3d8bbwe' -f $env:ProgramW6432)).'FullName' | Select-Object -First 1
)
}
else {
'{0}\Microsoft\WindowsApps\winget.exe' -f $env:LOCALAPPDATA
}
)
)
# Get upgradeable apps
## Introduce step
Write-Information -MessageData '# Get Winget output'
## Get output from "winget upgrade"
$WingetUpgradeable = [string[]](
cmd /c ('{0} upgrade' -f $WingetCliPath) | Where-Object -FilterScript {$_[0] -notmatch '\s'}
)
## Sort output alphabetically
$WingetUpgradeable = [string[]](
$WingetUpgradeable[0,1] + ($WingetUpgradeable[2 .. $WingetUpgradeable.IndexOf($WingetUpgradeable[-2])] | Sort-Object) + $WingetUpgradeable[-1]
)
## Show output
Write-Information -MessageData ($WingetUpgradeable -join [System.Environment]::NewLine)
# Find upgradeable apps
$AppsUpgradeable = [string[]](
$(
foreach ($App in $Apps) {
if ($WingetUpgradeable.Where{$_ -like ('*{0}*'-f$App)}.'Count' -eq 1) {
$App
}
}
) | Sort-Object
)
# Upgrade upgradeable apps
## Introduce step
Write-Information -MessageData ('{0}# Upgrade apps' -f ([System.Environment]::NewLine*2))
## Show no upgrades avaialble if none
if ($AppsUpgradeable.'Count' -le 0) {
Write-Information -MessageData 'Found no apps to update.'
}
## Upgrade upgradeable apps
foreach ($App in $AppsUpgradeable) {
Write-Information -MessageData (
'{0}## {1} / {2} "{3}"' -f (
$(if($AppsUpgradeable.IndexOf($App) -ne 0){[System.Environment]::NewLine}),
(1+$AppsUpgradeable.IndexOf($App)).ToString('0'*$AppsUpgradeable.'Count'.ToString().'Length'),
$AppsUpgradeable.'Count'.ToString(),
$App
)
)
$null = cmd /c (
'{0} {1} --id {2} --silent --accept-package-agreements --accept-source-agreements' -f (
$WingetCliPath,
$(if($App -in 'Eraser.Eraser','Microsoft.PowerToys'){'install'}else{'upgrade'}),
$App
)
)
Write-Information -MessageData ('Done. $? = {0}, $LASTEXITCODE = {1}.' -f $?.ToString(), $LASTEXITCODE)
} |
Yup, just reposting here for readability (from #1928 ), I ran into this same issue with |
I'm not sure if WinGet has enough information to provide the right hint to the user. Maybe it would make sense to have some documentation at Microsoft Learn to help provide some hints as to why certain error messages are presented. I'm sure there are edge cases where the hints might not be correct, but I would prefer to help users fall into the "pit of success". What were you thinking for better messaging @Trenly? |
It might be related to: |
There's 3 types of error that can lead to no applicable upgrade (at least from what I see in the code), and I'm sort of guessing at these, since I'm not quite familiar with that section of the workflow yet.
Currently, there are only 2 messages during the upgrade flow -
My thoughts are twofold
|
That sounds like a great improvement! |
[Policy] Command-Upgrade |
Originally posted by @MagicFirefly in #1191 (comment)
The text was updated successfully, but these errors were encountered: