winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 3377be41da5cca64ea4b962fdf5869e2459f5e99
parent 087cb29937f2d1866f163a7961a274f0945464d8
Author: KEINOS <github+fork-qiita-news@keinos.com>
Date:   Fri,  4 Jul 2025 04:37:38 +0000

Merge remote-tracking branch 'upstream/master'

Diffstat:
Msrc/PowerShell/Microsoft.WinGet.Client.Engine/Helpers/AppxModuleHelper.cs | 27+++++++++++++++++++++++++++
1 file changed, 27 insertions(+), 0 deletions(-)

diff --git a/src/PowerShell/Microsoft.WinGet.Client.Engine/Helpers/AppxModuleHelper.cs b/src/PowerShell/Microsoft.WinGet.Client.Engine/Helpers/AppxModuleHelper.cs @@ -357,6 +357,7 @@ namespace Microsoft.WinGet.Client.Engine.Helpers { HashSet<Architecture> architectures = new HashSet<Architecture>(); + // Read the override from the environment variable if it exists. string? environmentVariable = Environment.GetEnvironmentVariable(DependencyArchitectureEnvironmentVariable); if (environmentVariable != null) { @@ -377,6 +378,7 @@ namespace Microsoft.WinGet.Client.Engine.Helpers return architectures; } + // If there are any framework packages already installed, use the same architecture as them. var result = this.ExecuteAppxCmdlet( GetAppxPackage, new Dictionary<string, object> @@ -406,6 +408,31 @@ namespace Microsoft.WinGet.Client.Engine.Helpers } } + // Fall back to guessing from the current OS architecture. + // This may have issues on ARM64 because RuntimeInformation.OSArchitecture seems to just lie sometimes. + // See https://github.com/microsoft/winget-cli/issues/5020 + if (architectures.Count == 0) + { + var arch = RuntimeInformation.OSArchitecture; + this.pwshCmdlet.Write(StreamType.Verbose, $"OS architecture: {arch.ToString()}"); + + if (arch == Architecture.X64) + { + architectures.Add(Architecture.X64); + } + else if (arch == Architecture.X86) + { + architectures.Add(Architecture.X86); + } + else if (arch == Architecture.Arm64) + { + // Let deployment figure it out + architectures.Add(Architecture.Arm64); + architectures.Add(Architecture.X64); + architectures.Add(Architecture.X86); + } + } + return architectures; }