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.54k stars 1.39k forks source link

COM API "upgrade" not working when MinimumOSVersion is set in App Manifest! #4589

Open PatrickSchmidtSE opened 4 days ago

PatrickSchmidtSE commented 4 days ago

Brief description of your issue

When using the COM-API ( based on this project https://github.com/marticliment/WinGet-API-from-CSharp/tree/main/WindowsPackageManager%20Interop/WindowsPackageManager)
installation etc is working fine. Binaries coming from the project.

But "upgrading" via UpgradePackageAsync has been a very poor experience so far. Most of the upgrades fail with "NoApplicableInstaller" error code, while winget.exe upgrade does upgrade successfully.

I tested it with many packages, some work (Docker.DockerDesktop) , but many does lead to the above error ( like Java8 etc )

Steps to reproduce

Install a package like "snakefoot.snaketail" in an older version "1.9.7.0"

Then use the COM API to run the UpgradePackageAsync mechanic.

image

Expected behavior

Successfully upgrade to application with InstallResultStatus.OK

Actual behavior

InstallResultStatus.NoApplicableInstaller image By the documentation this means, that means that the Upgrade function could not find an available installer given the "options". i tried every options combination, architecture stuff, used all the switches to ignore stuff. Everyhing leads to the same result. I looked up via the installedVersion property which "Installer" is used and what characteristiks but they are all normal and even setting stuff to the settings the installedVersion has.. It all ends the same.

If i just put "winget upgrade --id snakefoot.snaketail --silent --force" it instantly downloads the msi and installs it successfully.

Proposed problem and solution So i think i got finally an idea what is happening:

Snakefoot has a MinimumOSVersion included

ManifestVersion: 1.6.0 MinimumOSVersion: 10.0.0.0 PackageIdentifier: snakefoot.snaketail

If you go to this check ---> (sadly OSFilter is NOT publicly changable )

image

You will see that the relevant function is using verifyversioninfow , which delivers a wrong comparism under WIndows10 if the manifest is not changed image

If i change that in my app manifest it works for my code, but not for the COM or detection from winCLI via COM. image

https://learn.microsoft.com/de-de/windows/win32/api/winbase/nf-winbase-verifyversioninfow

This must be fixed OR at least adressed via an OSFIlter ignore option :)

Environment

Windows Package Manager (Preview) v1.9.1763-preview
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.19045.4529
System Architecture: X64

Winget Directories
------------------------------------------------------------------------------------------------------
Logs                               %TEMP%\WinGet\defaultState
User Settings                      %LOCALAPPDATA%\Microsoft\WinGet\Settings\defaultState\settings.json
Portable Links Directory (User)    %LOCALAPPDATA%\Microsoft\WinGet\Links
Portable Links Directory (Machine) C:\Program Files\WinGet\Links
Portable Package Root (User)       %LOCALAPPDATA%\Microsoft\WinGet\Packages
Portable Package Root              C:\Program Files\WinGet\Packages
Portable Package Root (x86)        C:\Program Files (x86)\WinGet\Packages
Installer Downloads                %USERPROFILE%\Downloads

Links
---------------------------------------------------------------------------
Privacy Statement   https://aka.ms/winget-privacy
License Agreement   https://aka.ms/winget-license
Third Party Notices https://aka.ms/winget-3rdPartyNotice
Homepage            https://aka.ms/winget
Windows Store Terms https://www.microsoft.com/en-us/storedocs/terms-of-sale

Admin Setting                             State
--------------------------------------------------
LocalManifestFiles                        Disabled
BypassCertificatePinningForMicrosoftStore Disabled
InstallerHashOverride                     Disabled
LocalArchiveMalwareScanOverride           Disabled
ProxyCommandLineOptions                   Disabled
DefaultProxy                              Disabled
PatrickSchmidtSE commented 4 days ago

@JohnMcPMS thats the issue for my comment yesterday :)

PatrickSchmidtSE commented 3 days ago

This would also help for analyzing 🗡️

/// a lot of fields and no one requesting it. <<< I DOES NOW :D

/// DESIGN NOTE: /// GetManifest from IPackageVersion in AppInstallerRepositorySearch is not implemented in V1. That class has /// a lot of fields andc /// Gets the manifest of this package version. /// virtual Manifest::Manifest GetManifest() = 0;

PatrickSchmidtSE commented 3 days ago

So i think i got finally an idea what is happening: @JohnMcPMS This should be an easy fix for you and your team for the next release :)

Snakefoot has a MinimumOSVersion included

ManifestVersion: 1.6.0 MinimumOSVersion: 10.0.0.0 PackageIdentifier: snakefoot.snaketail

If you go to this check ---> (sadly OSFilter is NOT publicly changable )

image

You will see that the relevant function is using verifyversioninfow , which delivers a wrong comparism under WIndows10 if the manifest is not changed image

If i change that in my app manifest it works for my code, but not for the COM or detection from winCLI via COM. image

https://learn.microsoft.com/de-de/windows/win32/api/winbase/nf-winbase-verifyversioninfow

This must be fixed OR at least adressed via an OSFIlter ignore option :)

Packages that are working like VIM has NO MinOS on MetaData

image