Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
snickler opened this issue Feb 14, 2024 · 2 comments · Fixed by #4251 or #4392
Closed
Labels
In-PR Issue related to a PR Issue-Bug It either shouldn't be doing this or needs an investigation. PowerShell Issue related to WinGet PowerShell Module or cmdlet
Milestone

Comments

@snickler
Copy link
Contributor

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
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Triage Issue need to be triaged label Feb 14, 2024

This comment was marked as off-topic.

@denelon denelon added PowerShell Issue related to WinGet PowerShell Module or cmdlet Issue-Bug It either shouldn't be doing this or needs an investigation. and removed Needs-Triage Issue need to be triaged labels Feb 14, 2024
@snickler
Copy link
Contributor Author

snickler commented Mar 6, 2024

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

@microsoft-github-policy-service microsoft-github-policy-service bot added the In-PR Issue related to a PR label Mar 7, 2024
@denelon denelon added this to the 1.8 Client milestone Apr 19, 2024
msftrubengu added a commit that referenced this issue Apr 20, 2024
This PR enables arm64 for the Microsoft.WinGet.Client module.

There's an OS bug that causes an AV (see
#4251 (comment))
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)
msftrubengu pushed a commit that referenced this issue Apr 22, 2024
<!-- To check a checkbox place an "x" between the brackets. e.g: [x] -->

- [X] I have signed the [Contributor License
Agreement](https://cla.opensource.microsoft.com/microsoft/winget-pkgs).
- [X] This pull request is related to an issue.
  - Resolves: #4169
-----

This PR addresses an issue that prevents the WinGet Cmdlets from loading
in an Arm64 PowerShell 7.x environment.
###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/microsoft/winget-cli/pull/4251)
msftrubengu added a commit to msftrubengu/winget-cli that referenced this issue Apr 23, 2024
This PR enables arm64 for the Microsoft.WinGet.Client module.

There's an OS bug that causes an AV (see
microsoft#4251 (comment))
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 microsoft#4169

###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/microsoft/winget-cli/pull/4392)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
In-PR Issue related to a PR Issue-Bug It either shouldn't be doing this or needs an investigation. PowerShell Issue related to WinGet PowerShell Module or cmdlet
Projects
None yet
2 participants