WinGet Upgrade Workaround
Some WinGet apps cannot be upgraded by winget upgrade, even though the newer version is listed in the Relution app store. The cause is almost always a broken upstream manifest on the WinGet side — the upgrade command then fails with no applicable upgrade, package not found, no applicable installer found, or a related error.
Microsoft’s own workaround is to install the app again with the --force flag. The script below automates that recovery for a single WinGet app and can be run on devices with the Execute PowerShell script device action.
Script
The script is created as a PowerShell script under Scripts → Scripts via Add and then run on devices with the Execute PowerShell script device action or via Execute on device in the script list. It is executed by the Windows Companion in device context (SYSTEM). At the top of the script, the $AppIdentifier variable must be set to the exact WinGet identifier of the app to repair (for example Nextcloud.NextcloudDesktop).
Alternatively, the identifier can be passed in the Environment variables field (for example $AppIdentifier='Nextcloud.NextcloudDesktop'), so that one script can be used for several apps. In this case, the first line of the script must be removed, since it would otherwise overwrite the passed value.
By default, scripts have a Timeout (in minutes) of 5 minutes. Since the upgrade and forced installation of large apps can take longer, the value should be increased accordingly when creating the script or in the action (30 minutes at most).
Show full script
$AppIdentifier = 'You need to set this'
# Silent flags required by Relution (Companion runs as SYSTEM, no UI)
$SilentFlags = @(
'--silent',
'--disable-interactivity',
'--accept-package-agreements',
'--accept-source-agreements'
)
# Resolve winget.exe for SYSTEM context (DesktopAppInstaller package)
$winget = Resolve-Path 'C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*\winget.exe' -ErrorAction SilentlyContinue |
Select-Object -First 1 -ExpandProperty Path
if (-not $winget) {
Write-Error 'winget.exe not found in System context.'
exit 1
}
Write-Host "Using winget at: $winget"
# 1. Check if the app is installed
& $winget list --id $AppIdentifier --exact --accept-source-agreements --disable-interactivity | Out-Null
if ($LASTEXITCODE -ne 0) {
Write-Host "$AppIdentifier is not installed - nothing to do."
exit 0
}
# 2. Try the upgrade
& $winget upgrade --id $AppIdentifier --exact @SilentFlags
$code = $LASTEXITCODE
if ($code -eq 0) {
Write-Host "Upgrade completed successfully."
exit 0
}
Write-Warning "Upgrade failed with exit code $code."
# 3. Fallback for broken manifests / no applicable installer / package not found
$FallbackCodes = @(
-1978335189, # no applicable upgrade
-1978335215, # package not found
-1978335192, # no applicable installer found
-1978335216 # manifest / installer failure observed in practice
)
if ($code -in $FallbackCodes) {
Write-Warning "Retrying as 'install --force'..."
& $winget install --id $AppIdentifier --exact --force @SilentFlags
exit $LASTEXITCODE
}
exit $code
How it works
- The script resolves
winget.exeinsideC:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_*— the installation used by the Windows Companion in System context. - It calls
winget list --id <AppIdentifier> --exactto check whether the app is already installed. If not, the script exits without doing anything. - It calls
winget upgrade --id <AppIdentifier> --exactwith Relution’s mandatory silent flags →. The flags are splatted with@SilentFlagsso PowerShell passes each element as a separate argument — required for WinGet to parse them. If the upgrade succeeds, the script exits. - If the upgrade exits with one of the recoverable WinGet error codes, the script retries as
winget install --id <AppIdentifier> --exact --forcewith the same silent flags. The recoverable codes are:-1978335189— no applicable upgrade-1978335215— package not found-1978335192— no applicable installer found-1978335216— manifest / installer failure observed in practice
- Every other WinGet exit code is surfaced unchanged.
Detection relies solely on WinGet exit codes. The text output would depend on the device language and would differ between English and German Windows installations.
The execution state as well as the result and error output of the script (for example the Write-Host messages) can be viewed in the history of the script under Scripts → Scripts (Show result output, Show error output).
If the repair should run regularly, the script can also be executed on a schedule or on events via the Windows Script Configuration → policy configuration.