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

winget configure fails with Could not load file or assembly 'Microsoft.WinGet.Client.Engine' #4160

Open
JanDeDobbeleer opened this issue Feb 11, 2024 · 7 comments
Labels
Command-Configure Issue related to WinGet Configuration Issue-Bug It either shouldn't be doing this or needs an investigation.

Comments

@JanDeDobbeleer
Copy link

Brief description of your issue

I'm trying to run a working configuration (provided by @denelon here) but it fails on my machine using the same configuration.

# yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.2
properties:
  resources:
    - resource: Microsoft.WinGet.DSC/WinGetPackage
      id: ohmyposh
      directives:
        description: Install Oh My Posh
        allowPrerelease: true
      settings:
        id: JanDeDobbeleer.OhMyPosh
        source: winget
  configurationVersion: 0.2.0

Steps to reproduce

Not sure, it seems to be device/environment specific.

Expected behavior

It succeeds in applying the configuration.

Actual behavior

It crashed with:

2024-02-11 16:11:28.178 [CORE] WinGet, version [1.7.3481-preview], activity [{E2EE6697-1F5F-4191-B391-FF74A7A0258C}]
2024-02-11 16:11:28.178 [CORE] OS: Windows.Desktop v10.0.22000.2538
2024-02-11 16:11:28.178 [CORE] Command line Args: "C:\Users\jan\AppData\Local\Microsoft\WindowsApps\winget.exe" configure C:\Users\jan\Documents\oh-my-posh.dsc.yaml --logs
2024-02-11 16:11:28.178 [CORE] Package: Microsoft.DesktopAppInstaller v1.22.3481.0
2024-02-11 16:11:28.178 [CORE] IsCOMCall:0; Caller: winget-cli
2024-02-11 16:11:28.181 [CLI ] WinGet invoked with arguments: 'configure' 'C:\Users\jan\Documents\oh-my-posh.dsc.yaml' '--logs'
2024-02-11 16:11:28.181 [CLI ] Found subcommand: configure
2024-02-11 16:11:28.181 [CLI ] Leaf command to execute: root:configure
2024-02-11 16:11:28.181 [CLI ] Executing command: configure
2024-02-11 16:11:33.915 [CONF] Configuration unit WinGetPackage[ohmyposh] failed with code 0x8a15c105 and error message:
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)
Microsoft.Management.Configuration.Processor.Exceptions.InvokeDscResourceException: Failed when calling `Test` for resource: WinGetPackage [Microsoft.WinGet.DSC] Message: '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)
'
   at Microsoft.Management.Configuration.Processor.DscModule.DscModuleV2.InvokeTestResource(PowerShell pwsh, ValueSet settings, String name, ModuleSpecification moduleSpecification)
   at Microsoft.Management.Configuration.Processor.Runspaces.HostedEnvironment.InvokeTestResource(ValueSet settings, String name, ModuleSpecification moduleSpecification)
   at Microsoft.Management.Configuration.Processor.Unit.ConfigurationUnitProcessor.TestSettings()
2024-02-11 16:11:33.915 [CLI ] Terminating context: 0x8a15c005 at C:\__w\1\s\external\pkg\src\AppInstallerCLICore\Workflows\ConfigurationFlow.cpp:3f9

Environment

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

Windows: Windows.Desktop v10.0.22000.2538
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 11, 2024

This comment was marked as off-topic.

@stephengillie stephengillie added Command-Configure Issue related to WinGet Configuration Issue-Bug It either shouldn't be doing this or needs an investigation. and removed Needs-Triage Issue need to be triaged labels Feb 12, 2024
@denelon
Copy link
Contributor

denelon commented Feb 12, 2024

@JanDeDobbeleer I'm asking the engineering team to take a look. I wasn't able to reproduce the error.

@denelon
Copy link
Contributor

denelon commented Feb 20, 2024

It would help to know which module version you have and the directory structure of the module, that dl must be under net6.0-windows10.0.22000\DirectDependencies.

@JanDeDobbeleer
Copy link
Author

This is run with --verbose

2024-02-20 20:25:22.190 [CORE] WinGet, version [1.7.3481-preview], activity [{B42988C8-340C-4810-BAFB-6AC7BEFE0FB3}]
2024-02-20 20:25:22.190 [CORE] OS: Windows.Desktop v10.0.22000.2538
2024-02-20 20:25:22.190 [CORE] Command line Args: "C:\Users\jan\AppData\Local\Microsoft\WindowsApps\winget.exe" configure C:\Users\jan\AppData\Local\Packages\Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe\LocalState\oh-my-posh.configuration.yml --logs --verbose
2024-02-20 20:25:22.190 [CORE] Package: Microsoft.DesktopAppInstaller v1.22.3481.0
2024-02-20 20:25:22.190 [CORE] IsCOMCall:0; Caller: winget-cli
2024-02-20 20:25:22.196 [CLI ] WinGet invoked with arguments: 'configure' 'C:\Users\jan\AppData\Local\Packages\Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe\LocalState\oh-my-posh.configuration.yml' '--logs' '--verbose'
2024-02-20 20:25:22.196 [CLI ] Found subcommand: configure
2024-02-20 20:25:22.197 [CLI ] Leaf command to execute: root:configure
2024-02-20 20:25:22.197 [CLI ] Executing command: configure
2024-02-20 20:25:22.214 [CONF] Launching process for configuration processing...
2024-02-20 20:25:22.220 [CONF]   Configuration remote PID is 10084
2024-02-20 20:25:22.447 [CONF] ... configuration processing connection established.
2024-02-20 20:25:22.449 [CONF] Applying built in additional module path: C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.22.3481.0_arm64__8wekyb3d8bbwe\ExternalModules
2024-02-20 20:25:22.679 [CONF] [CONF] Parsing configuration set:
2024-02-20 20:25:22.679 [CONF] # yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.2
properties:
  resources:
    - resource: Microsoft.WinGet.DSC/WinGetPackage
      id: ohmyposh
      directives:
        description: Install Oh My Posh
        allowPrerelease: true
      settings:
        id: JanDeDobbeleer.OhMyPosh
        source: winget
  configurationVersion: 0.2.0

2024-02-20 20:25:22.679 [CONF] [YAML] Detected UTF-8
2024-02-20 20:25:22.961 [CONF] Creating set processor for `oh-my-posh.configuration.yml`...
2024-02-20 20:25:24.025 [CONF] Using winget module path
2024-02-20 20:25:24.025 [CONF]   Effective module path:
C:\Users\jan\AppData\Local\Microsoft\WinGet\Configuration\Modules;C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.22.3481.0_arm64__8wekyb3d8bbwe\ExternalModules;C:\Users\jan\Documents\PowerShell\Modules;C:\Program Files\PowerShell\Modules;c:\program files\windowsapps\microsoft.desktopappinstaller_1.22.3481.0_arm64__8wekyb3d8bbwe\configurationremotingserver\Modules;c:\program files (arm)\powershell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
2024-02-20 20:25:26.858 [CONF] PowerShellCommands: ['Import-Module' Parameters: FullyQualifiedName = '@{ ModuleName = 'PSDesiredStateConfiguration'; ModuleVersion = '2.0.7'; MaximumVersion = '2.999999999' }' ]

2024-02-20 20:25:26.858 [CONF] ... done creating set processor.
2024-02-20 20:25:26.880 [CONF] Getting unit details [ReadOnly] for: Microsoft.WinGet.DSC/WinGetPackage
2024-02-20 20:25:30.804 [CONF] Creating set processor for `oh-my-posh.configuration.yml`...
2024-02-20 20:25:30.861 [CONF] Using winget module path
2024-02-20 20:25:30.861 [CONF]   Effective module path:
C:\Users\jan\AppData\Local\Microsoft\WinGet\Configuration\Modules;C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.22.3481.0_arm64__8wekyb3d8bbwe\ExternalModules;C:\Users\jan\Documents\PowerShell\Modules;C:\Program Files\PowerShell\Modules;c:\program files\windowsapps\microsoft.desktopappinstaller_1.22.3481.0_arm64__8wekyb3d8bbwe\configurationremotingserver\Modules;c:\program files (arm)\powershell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
2024-02-20 20:25:31.040 [CONF] ... done creating set processor.
2024-02-20 20:25:31.043 [CONF] Creating unit processor for: Microsoft.WinGet.DSC/WinGetPackage...
2024-02-20 20:25:31.359 [CONF] ... done creating unit processor.
2024-02-20 20:25:31.359 [CONF] Using unit from location: C:\Users\jan\AppData\Local\Microsoft\WinGet\Configuration\Modules\Microsoft.WinGet.DSC\0.2.0\Microsoft.WinGet.DSC.psd1
2024-02-20 20:25:31.362 [CONF] Invoking `Test` for resource: Microsoft.WinGet.DSC/WinGetPackage...
2024-02-20 20:25:31.654 [CONF] Microsoft.Management.Configuration.Processor.Exceptions.InvokeDscResourceException: Failed when calling `Test` for resource: WinGetPackage [Microsoft.WinGet.DSC] Message: '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)
'
   at Microsoft.Management.Configuration.Processor.DscModule.DscModuleV2.InvokeTestResource(PowerShell pwsh, ValueSet settings, String name, ModuleSpecification moduleSpecification)
   at Microsoft.Management.Configuration.Processor.Runspaces.HostedEnvironment.InvokeTestResource(ValueSet settings, String name, ModuleSpecification moduleSpecification)
   at Microsoft.Management.Configuration.Processor.Unit.ConfigurationUnitProcessor.TestSettings()
2024-02-20 20:25:31.654 [CONF] ... done invoking `Test`.
2024-02-20 20:25:31.678 [CONF] Configuration unit WinGetPackage[ohmyposh] failed with code 0x8a15c105 and error message:
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)
Microsoft.Management.Configuration.Processor.Exceptions.InvokeDscResourceException: Failed when calling `Test` for resource: WinGetPackage [Microsoft.WinGet.DSC] Message: '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)
'
   at Microsoft.Management.Configuration.Processor.DscModule.DscModuleV2.InvokeTestResource(PowerShell pwsh, ValueSet settings, String name, ModuleSpecification moduleSpecification)
   at Microsoft.Management.Configuration.Processor.Runspaces.HostedEnvironment.InvokeTestResource(ValueSet settings, String name, ModuleSpecification moduleSpecification)
   at Microsoft.Management.Configuration.Processor.Unit.ConfigurationUnitProcessor.TestSettings()
2024-02-20 20:25:31.679 [CLI ] Terminating context: 0x8a15c005 at C:\__w\1\s\external\pkg\src\AppInstallerCLICore\Workflows\ConfigurationFlow.cpp:3f9

@JanDeDobbeleer
Copy link
Author

@denelon I had a look at the module paths and here are the versions which are present:

  • C:\Users\jan\AppData\Local\Microsoft\WinGet\Configuration\Modules - 1.21.2311.09003
  • C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.22.3481.0_arm64__8wekyb3d8bbwe\ExternalModules - N/A
  • C:\Users\jan\Documents\PowerShell\Modules - 1.21.2311.09003
  • C:\Program Files\PowerShell\Modules - N/A
  • c:\program files\windowsapps\microsoft.desktopappinstaller_1.22.3481.0_arm64__8wekyb3d8bbwe\configurationremotingserver\Modules - N/A
  • c:\program files (arm)\powershell\Modules - N/A
  • C:\Program Files\WindowsPowerShell\Modules - N/A
  • C:\Windows\system32\WindowsPowerShell\v1.0\Modules - N/A

@msftrubengu
Copy link
Contributor

1.21.2311.09003 is for the 1.6.3133.0 module version. I'm guessing if you run get-module microsoft.winget.client -ListAvailable in a pwsh session you will see two results (you need to add the local app data path to the psmodulepath tho)

Can you try loading the client module directly in pwsh from both locations? It might be easier to load the psd1 directly.

@JanDeDobbeleer
Copy link
Author

@msftrubengu to be honest, I just want to be able to run winget configure and not deal with DLL hell. From a user POV, this should simply work:

  • install winget
  • run winget configure
  • done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Command-Configure Issue related to WinGet Configuration Issue-Bug It either shouldn't be doing this or needs an investigation.
Projects
None yet
Development

No branches or pull requests

4 participants