winget-cli icon indicating copy to clipboard operation
winget-cli copied to clipboard

Microsoft.WinGet.Client PowerShell Module failing to load on Arm64 in PowerShell 7.x

Open snickler opened this issue 1 year ago • 1 comments

Brief description of your issue

On Windows Arm64 machines running PowerShell 7.x, the Microsoft.WinGet.Client.Engine and Microsoft.WinGet.Client.Cmdlets assemblies fail to load properly since only x86 and x64 assemblies are bundled with the NuGet package.

Steps to reproduce

  1. Run Install-Module Microsoft.WinGet.Client -RequiredVersion 0.2.1 -Scope User in PowerShell 7.4.1+
  2. Run Get-WinGetSettings Cmdlet
  3. Run Get-WinGetVersion Cmdlet

Expected behavior

A list of settings schema and the actual WinGet version

Actual behavior

Get-WinGetVersion: Could not load file or assembly 'Microsoft.WinGet.Client.Engine, Version=1.21.0.0, Culture=neutral, PublicKeyToken=null'. Uncaught exception during type initialization. (0x80131534)

Also, when using the PowerToys Command Not Found functionality, it fails to load Microsoft.WinGet.Client.Cmdlets.dll for the same reason, due to the logic in the Microsoft.WinGet.Client module

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
NestedModules = if ($env:PROCESSOR_ARCHITECTURE -like 'x86')
{
    if ($PSEdition -eq 'Core')
    {
        "runtimes\win10-x86\lib\net6.0-windows10.0.22000.0\Microsoft.WinGet.Client.Cmdlets.dll"
    }
    else
    {
        "runtimes\win10-x86\lib\net48\Microsoft.WinGet.Client.Cmdlets.dll"
    }
}
else
{
    if ($PSEdition -eq 'Core')
    {
        "runtimes\win10-x64\lib\net6.0-windows10.0.22000.0\Microsoft.WinGet.Client.Cmdlets.dll"
    }
    else
    {
        "runtimes\win10-x64\lib\net48\Microsoft.WinGet.Client.Cmdlets.dll"
    }
}

The Microsoft.WinGet.Client package only includes dlls targeting win10-x86 and win10-x64 runtimes. For completion, the packages must also include win10-arm64 compiled dlls and dependencies, along with the logic changed to account for Arm64 process architecture when loading dlls properly.

Environment

Windows Package Manager (Preview) v1.7.3481-preview
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.23620.1000
System Architecture: Arm64
Package: Microsoft.DesktopAppInstaller v1.22.3481.0

Winget Directories
-----------------------------------------------------------------------------------------------------------------------
Logs                               %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\Diag…
User Settings                      %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\sett…
Portable Links Directory (User)    %LOCALAPPDATA%\Microsoft\WinGet\Links
Portable Links Directory (Machine) C:\Program Files\WinGet\Links
Portable Package Root (User)       %LOCALAPPDATA%\Microsoft\WinGet\Packages
Portable Package Root              C:\Program Files\WinGet\Packages
Portable Package Root (x86)        C:\Program Files (x86)\WinGet\Packages
Installer Downloads                %USERPROFILE%\Downloads

Links
---------------------------------------------------------------------------
Privacy Statement   https://aka.ms/winget-privacy
License Agreement   https://aka.ms/winget-license
Third Party Notices https://aka.ms/winget-3rdPartyNotice
Homepage            https://aka.ms/winget
Windows Store Terms https://www.microsoft.com/en-us/storedocs/terms-of-sale

Admin Setting                             State
--------------------------------------------------
LocalManifestFiles                        Disabled
BypassCertificatePinningForMicrosoftStore Disabled
InstallerHashOverride                     Disabled
LocalArchiveMalwareScanOverride           Disabled

snickler avatar Feb 14 '24 20:02 snickler

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

github-actions[bot] avatar Feb 14 '24 20:02 github-actions[bot]

v1.7.10651 issues:

❯ Import-Module Microsoft.WinGet.Client -Verbose
VERBOSE: Loading module from path 'C:\Users\jerem\OneDrive\Documents\PowerShell\Modules\Microsoft.WinGet.Client\1.7.10651\Microsoft.WinGet.Client.psd1'.
VERBOSE: Loading 'FormatsToProcess' from path 'C:\Users\jerem\OneDrive\Documents\PowerShell\Modules\Microsoft.WinGet.Client\1.7.10651\Format.ps1xml'.
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.WinGet.Client.
VERBOSE: Loading module from path 'C:\Users\jerem\OneDrive\Documents\PowerShell\Modules\Microsoft.WinGet.Client\1.7.10651\net6.0-windows10.0.22000.0\Microsoft.WinGet.Client.Cmdlets.dll'.
Import-Module: Arm64

image

snickler avatar Mar 06 '24 17:03 snickler