Download MS Store package for target OS by JohnMcPMS · Pull Request #5689 · microsoft/winget-cli
Fixes #4996
Change
Adds the ability to specify the target OS version for downloads from the Microsoft Store. This is achieved by filtering the set of applicable platforms in GetSfsPackageFileSupportedPlatforms further than the existing platform targeting. Now they must also have a minimum specified OS version >= the target OS version.
winget.exe download has a new parameter --os-version. This is a UINT64 version (4 part version with 2^16-1 maximum value for each part) that should be given as the target OS version.
COM DownloadOptions has a new property TargetOSVersion, which is a string of the same format as above.
PowerShell Export-WinGetPackage has a new parameter -TargetOSVersion, which is also a string of the same format.
Also added the previously implemented options to skip the license download (--skip-license) and the target platform (--platform) to COM (SkipMicrosoftStoreLicense and Platform) and PowerShell (-SkipMicrosoftStoreLicense and -Platform).
Validation
Added a test to the existing ones for specifying a lower target version.
Manually verified that without the parameter provided, for 9NHMG4BJKMDG (as exemplified in the issue) we download version 27920.1.1.0. Specifying version 10.0.22000.0 as the target OS, we download package version 22000.52.238.0 which has in it's manifest:
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.21251.0" MaxVersionTested="10.0.22000.2652" />