KEMBAR78
Download MS Store package for target OS by JohnMcPMS · Pull Request #5689 · microsoft/winget-cli · GitHub
Skip to content

Conversation

JohnMcPMS
Copy link
Member

@JohnMcPMS JohnMcPMS commented Aug 26, 2025

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" />
Microsoft Reviewers: Open in CodeFlow

yao-msft
yao-msft previously approved these changes Aug 26, 2025
Manifest::PlatformEnum requiredPlatform,
const std::optional<Utility::UInt64Version>& targetOSVersion)
{
UNREFERENCED_PARAMETER(targetOSVersion);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove

AuthenticationArguments AuthenticationArguments;
}

[contract(Microsoft.Management.Deployment.WindowsPackageManagerContract, 13)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the contract version comment in line 5 is still 1.12

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correctly so; that comment means that it has already been incremented for 1.12.

std::string locale,
AppInstaller::Authentication::AuthenticationArguments authArgs);

void TargetOSVersion(std::optional<Utility::UInt64Version> targetOSVersion);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we move it to constructor? I don't see it needs to be changed after it's created.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not that concerned with invariants in an internal type and properties are much more optionally-set friendly. I do dislike large numbers of arguments to functions though.

{
// Not passing in required platform for dependencies. Dependencies are mostly Windows.Universal.
auto dependencyPackages = PopulateSfsAppFileToMSStoreDownloadFileVector(dependencyEntry.GetFiles(), requiredArchitecture);
auto dependencyPackages = PopulateSfsAppFileToMSStoreDownloadFileVector(dependencyEntry.GetFiles(), requiredArchitecture, Manifest::PlatformEnum::Unknown, targetOSVersion);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible for dependency packages to have higher min OS version than main package? Maybe we can pass nullopt for targetOSVersion?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are talking about MSIX packages and scenarios where no versions have been removed (security, etc.), then I would say no. There must have been a dependency that was also installable on the target OS version at some time.

@JohnMcPMS JohnMcPMS merged commit bc7a073 into microsoft:master Aug 27, 2025
9 checks passed
@JohnMcPMS JohnMcPMS deleted the download-target-os branch August 27, 2025 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ability for winget to download a Microsoft Store application for specific Windows build

2 participants