Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ private HashSet<Architecture> InitFrameworkArchitectures()
{
HashSet<Architecture> architectures = new HashSet<Architecture>();

// Read the override from the environment variable if it exists.
string? environmentVariable = Environment.GetEnvironmentVariable(DependencyArchitectureEnvironmentVariable);
if (environmentVariable != null)
{
Expand All @@ -377,6 +378,7 @@ private HashSet<Architecture> InitFrameworkArchitectures()
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>
Expand Down Expand Up @@ -406,6 +408,31 @@ private HashSet<Architecture> InitFrameworkArchitectures()
}
}

// 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;
}

Expand Down
Loading