microsoft / winget-cli

WinGet is the Windows Package Manager. This project includes a CLI (Command Line Interface), PowerShell modules, and a COM (Component Object Model) API (Application Programming Interface).
https://learn.microsoft.com/windows/package-manager/
MIT License
22.99k stars 1.43k forks source link

`install-WinGetPackage` reinstalling packages #3455

Open kdpuvvadi opened 1 year ago

kdpuvvadi commented 1 year ago

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 commented 1 year ago

cc @denelon, #221

kdpuvvadi commented 1 year ago

tested this on both 1.5.1881 and 1.6.1573-preview

jantari commented 10 months ago

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 commented 6 months ago

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

kdpuvvadi commented 5 months ago

Tested this on 1.7.10861 and issue is still present

kdpuvvadi commented 5 months ago

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 = ""
        }