commit 1d99a668588e6e458d28142f7ae4f66c17c7bc94 parent 2e14846ad20b2981028831cd20b5b2fe4b080845 Author: Ruben Guerrero <rubengu@microsoft.com> Date: Fri, 19 Apr 2024 18:54:42 -0700 Enable Microsoft.WinGet.Client arm64 support (#4392) This PR enables arm64 for the Microsoft.WinGet.Client module. There's an OS bug that causes an AV (see https://github.com/microsoft/winget-cli/pull/4251#issuecomment-1989102892) in arm64 devices that was fixed in a newer Windows build. The AV message is just shown for PowerShell Core. In Windows PowerShell no error message is displayed but it won't display progress either. Regardless, the winget install/uninstall operation still happens as the progress is shown after we asked winget to install the app. The configuration module doesn't get affected by the OS bug, so there's no need to disable progress. To keep showing progress the module now looks at the OS version. If the processor architecture is arm64 and the OS version is lower than 10.0.26068.0 progress is disabled in the module. I verified manually on arm64 builds with and without the fix. Fixes #4169 ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/microsoft/winget-cli/pull/4392) Diffstat:
3 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/src/PowerShell/Microsoft.WinGet.Client.Cmdlets/Resolver/ModuleInit.cs b/src/PowerShell/Microsoft.WinGet.Client.Cmdlets/Resolver/ModuleInit.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // <copyright file="ModuleInit.cs" company="Microsoft Corporation"> // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // </copyright> @@ -23,7 +23,7 @@ namespace Microsoft.WinGet.Resolver /// </summary> public class ModuleInit : IModuleAssemblyInitializer, IModuleAssemblyCleanup { - private static readonly IEnumerable<Architecture> ValidArchs = new Architecture[] { Architecture.X86, Architecture.X64 }; + private static readonly IEnumerable<Architecture> ValidArchs = new Architecture[] { Architecture.X86, Architecture.X64, Architecture.Arm64 }; /// <inheritdoc/> public void OnImport() diff --git a/src/PowerShell/Microsoft.WinGet.Client.Engine/Helpers/OperationWithProgressBase.cs b/src/PowerShell/Microsoft.WinGet.Client.Engine/Helpers/OperationWithProgressBase.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // <copyright file="OperationWithProgressBase.cs" company="Microsoft Corporation"> // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // </copyright> @@ -7,6 +7,7 @@ namespace Microsoft.WinGet.Client.Engine.Helpers { using System; + using System.Runtime.InteropServices; using System.Threading.Tasks; using Microsoft.WinGet.Common.Command; using Microsoft.WinGet.Resources; @@ -19,6 +20,24 @@ namespace Microsoft.WinGet.Client.Engine.Helpers /// <typeparam name="TProgressData">Progress data.</typeparam> internal abstract class OperationWithProgressBase<TOperationResult, TProgressData> { + private static bool isProgressEnabled; + + static OperationWithProgressBase() + { + // Progress on arm64 will produce an AV because there's an OS bug where marshaling structs over a certain size fail. + // Fix is in 10.0.26068.0, for build before that disable progress. + if (RuntimeInformation.ProcessArchitecture == Architecture.Arm64) + { + var minWindowsVersion = new Version(10, 0, 26068, 0); + var osVersion = Environment.OSVersion.Version; + isProgressEnabled = osVersion.CompareTo(minWindowsVersion) >= 0; + } + else + { + isProgressEnabled = true; + } + } + /// <summary> /// Initializes a new instance of the <see cref="OperationWithProgressBase{TOperationResult, TProgressData}"/> class. /// </summary> @@ -64,7 +83,11 @@ namespace Microsoft.WinGet.Client.Engine.Helpers public async Task<TOperationResult> ExecuteAsync(Func<IAsyncOperationWithProgress<TOperationResult, TProgressData>> func) { var operation = func(); - operation.Progress = this.Progress; + + if (isProgressEnabled) + { + operation.Progress = this.Progress; + } try { diff --git a/src/PowerShell/Microsoft.WinGet.Configuration.Engine/Commands/ConfigurationCommand.cs b/src/PowerShell/Microsoft.WinGet.Configuration.Engine/Commands/ConfigurationCommand.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // <copyright file="ConfigurationCommand.cs" company="Microsoft Corporation"> // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // </copyright>