winget-cli icon indicating copy to clipboard operation
winget-cli copied to clipboard

`install-WinGetPackage` reinstalling packages

Open kdpuvvadi opened this issue 1 year ago • 6 comments

Brief description of your issue

install-WinGetPackage installing the package regardless installation status, update availability. I'm aware there that Update-WinGetPackage cmdlet is available but install cmdlet should also consider the installation status.

Steps to reproduce

I'm using npp as base here.

check application status

$ Get-Command notepad++

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     notepad++.exe                                      8.5.4.0    C:\Program Files\Notepad++\notepad++.exe

Try installing with winget client

$ winget install Notepad++.Notepad++
Found an existing package already installed. Trying to upgrade the installed package...
No available upgrade found.
No newer package versions are available from the configured sources.

try same with install-WinGetPackage

install-WinGetPackage Notepad++.Notepad++ -Verbose -Debug

Confirm
Are you sure you want to perform this action?
Performing the operation "Install-WinGetPackage" on target "Notepad++ [Notepad++.Notepad++] Version
 8.5.4".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): A

InstallerError Code Status RebootRequired ExtendedErrorCode CorrelationData
-------------- ---- ------ -------------- ----------------- ---------------
0                  Ok     False

Expected behavior

Skip install if no update available

Actual behavior

Reinstalling the package

Environment

Windows Package Manager v1.5.1572

Windows: Windows.Desktop v10.0.19045.3208
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.20.1572.0

kdpuvvadi avatar Jul 20 '23 09:07 kdpuvvadi

cc @denelon, #221

kdpuvvadi avatar Jul 20 '23 09:07 kdpuvvadi

tested this on both 1.5.1881 and 1.6.1573-preview

kdpuvvadi avatar Jul 20 '23 09:07 kdpuvvadi

This is definitely still an issue:

~\configs\Windows on  win-setup-admincoprocess
❯ winget install --source winget --id Google.Chrome --scope machine --silent
Found an existing package already installed. Trying to upgrade the installed package...
No available upgrade found.
No newer package versions are available from the configured sources.

~\configs\Windows on  win-setup-admincoprocess
❯ Install-WinGetPackage -Source winget -Id Google.Chrome -Scope System -Mode Silent -Verbose
VERBOSE: Performing the operation "Install-WinGetPackage" on target "Google Chrome [Google.Chrome] Version 119.0.6045.160".

InstallerErrorCode Status RebootRequired ExtendedErrorCode CorrelationData
------------------ ------ -------------- ----------------- ---------------
0                  Ok     False


~\configs\Windows on  win-setup-admincoprocess took 1m31s
❯ winget --version
v1.6.3133

~\configs\Windows on  win-setup-admincoprocess
❯ get-module  -Name Microsoft.Winget.Client

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Binary     1.6.3133.0            Microsoft.Winget.Client             {Add-WinGetSource, Assert-WinGetPackageManager, Disable-WinGetSetting, Enable-WinGetSetting…}

Another, related problem is that Install-WinGetPackage does not have a parameter for the --no-upgrade option.

jantari avatar Nov 23 '23 23:11 jantari

Latest PowerShell module v1.7.10661, this is still an issue.

jantari avatar Mar 13 '24 10:03 jantari

Tested this on 1.7.10861 and issue is still present

kdpuvvadi avatar Apr 08 '24 06:04 kdpuvvadi

From the source it's seems just passing all the args to the winget client but trying with same args used with ps module with winget resulting in different result.

 if($Result.count -eq 1 -or $Local) {
            & "WinGet" $WinGetInstallArgs
            $Result = ""
        }

kdpuvvadi avatar Apr 08 '24 06:04 kdpuvvadi