Install-Module Microsoft.WinGet.Client fails with TypeInitializationException in FilesystemExtensions due to stale PackageManagement temp folder permissions

Offen
#6,605 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
48/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
powershell
Bereich
cli

Rechercherichtung

Start by reproducing the failure with Install-Module -Name Microsoft.WinGet.Client and inspect the reported PackageManagement FilesystemExtensions.MakeSafeFileName initialization error. The issue names no repository files or tests, so locate the relevant implementation and tests from that entry point; done means the NuGet provider bootstrap succeeds despite the stale temp folder permissions.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Command-Install Issue-Bug
Relevant area(s)

WinGet CLI

Relevant command(s)

winget install

Brief description of your issue

Attempting to install the Microsoft.WinGet.Client PowerShell module fails during the NuGet provider bootstrap sequence. Instead of prompting for the provider installation, the PackageManagement engine throws an unhandled TypeInitializationException for Microsoft.PackageManagement.Internal.Utility.Extensions.FilesystemExtensions. This renders Install-Module, Install-PackageProvider, and Get-PackageProvider unusable in the current session, preventing the WinGet client module from being installed.

Steps to reproduce

Open Windows PowerShell (or PowerShell) as a standard user or administrator.

Run Install-Module -Name Microsoft.WinGet.Client.

When prompted to install the NuGet provider, respond Y (Yes).

Expected behavior

The NuGet provider (version 2.8.5.201 or newer) should install successfully, followed by the installation of the Microsoft.WinGet.Client module from the PowerShell Gallery.

Actual behavior

The provider bootstrap fails immediately with a TypeInitializationException. The full error trace shows the failure originates in FilesystemExtensions.MakeSafeFileName, cascading through the plugin initialization logic of PackageManagement.

PackageManagement\Install-PackageProvider : Unhandled Exception - Message:'The type initializer for
'Microsoft.PackageManagement.Internal.Utility.Extensions.FilesystemExtensions' threw an exception.'
Name:'TypeInitializationException' Stack Trace:' at
Microsoft.PackageManagement.Internal.Utility.Extensions.FilesystemExtensions.MakeSafeFileName(String input)
at Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicType.DefineDynamicType(Type interfaceType)
at Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicType..ctor(Type interfaceType, OrderedDictionary2 methods, List2 delegates, List`1 stubs)
...
at Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider.get_SelectedProviders()

PS C:\WINDOWS\system32> Install-Module -Name Microsoft.WinGet.Client

NuGet provider is required to continue
PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The
NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or
'C:\Users\Taylo\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by
running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install
and import the NuGet provider now?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"):
PS C:\WINDOWS\system32> Install-Module -Name Microsoft.WinGet.Client

NuGet provider is required to continue
PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The
NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or
'C:\Users\Taylo\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by
running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install
and import the NuGet provider now?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): Y
PackageManagement\Install-PackageProvider : Unhandled Exception - Message:'The type initializer for
'Microsoft.PackageManagement.Internal.Utility.Extensions.FilesystemExtensions' threw an exception.'
Name:'TypeInitializationException' Stack Trace:' at
Microsoft.PackageManagement.Internal.Utility.Extensions.FilesystemExtensions.MakeSafeFileName(String input)
at Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicType.DefineDynamicType(Type interfaceType)
at Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicType..ctor(Type interfaceType, OrderedDictionary2 methods, List2 delegates, List1 stubs) at Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicType.<>c__DisplayClass9_0.<Create>b__3() at Microsoft.PackageManagement.Internal.Utility.Extensions.DictionaryExtensions.GetOrAdd[TKey,TValue](IDictionary2
dictionary, TKey key, Func1 valueFunction) at Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicType.Create(Type tInterface, OrderedDictionary2
instanceMethods, List2 delegateMethods, List1 stubMethods, List2 usedInstances) at Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicInterface.CreateProxy(Type tInterface, Object[] instances) at Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicInterface.DynamicCast[TInterface](Object[] instances) at Microsoft.PowerShell.PackageManagement.Cmdlets.CmdletBase.SelectProviders(String[] names) at Microsoft.PowerShell.PackageManagement.Cmdlets.CmdletWithProvider.get_SelectedProviders() at Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider.get_SelectedProviders() at Microsoft.PowerShell.PackageManagement.Cmdlets.CmdletWithProvider.<get_CachedSelectedProviders>b__23_0() at Microsoft.PackageManagement.Internal.Utility.Extensions.DictionaryExtensions.GetOrAdd[TKey,TValue](IDictionary2
dictionary, TKey key, Func`1 valueFunction)
at Microsoft.PowerShell.PackageManagement.Cmdlets.CmdletWithProvider.get_CachedSelectedProviders()
at Microsoft.PowerShell.PackageManagement.Cmdlets.CmdletWithProvider.GenerateDynamicParameters()
at Microsoft.PowerShell.PackageManagement.Cmdlets.AsyncCmdlet.<>c__DisplayClass83_0.b__0()'
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7468 char:21

  • ... $null = PackageManagement\Install-PackageProvider -Name $script:N ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (Microsoft.Power...PackageProvider:InstallPackageProvider) [Install-
      PackageProvider], Exception
    • FullyQualifiedErrorId : UnhandledException,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvid
      er

PackageManagement\Import-PackageProvider : No match was found for the specified search criteria and provider name
'NuGet'. Try 'Get-PackageProvider -ListAvailable' to see if the provider exists on the system.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7474 char:21

  • ... $null = PackageManagement\Import-PackageProvider -Name $script:Nu ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidData: (NuGet:String) [Import-PackageProvider], Exception
    • FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.ImportPackagePr
      ovider

PackageManagement\Get-PackageProvider : Unhandled Exception - Message:'The type initializer for
'Microsoft.PackageManagement.Internal.Utility.Extensions.FilesystemExtensions' threw an exception.'
Name:'TypeInitializationException' Stack Trace:' at
Microsoft.PackageManagement.Internal.Utility.Extensions.FilesystemExtensions.MakeSafeFileName(String input)
at Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicType.DefineDynamicType(Type interfaceType)
at Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicType..ctor(Type interfaceType, OrderedDictionary2 methods, List2 delegates, List1 stubs) at Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicType.<>c__DisplayClass9_0.<Create>b__3() at Microsoft.PackageManagement.Internal.Utility.Extensions.DictionaryExtensions.GetOrAdd[TKey,TValue](IDictionary2
dictionary, TKey key, Func1 valueFunction) at Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicType.Create(Type tInterface, OrderedDictionary2
instanceMethods, List2 delegateMethods, List1 stubMethods, List`2 usedInstances)
at Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicInterface.CreateProxy(Type tInterface, Object[]
instances)
at Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicInterface.DynamicCast[TInterface](Object[]
instances)
at Microsoft.PowerShell.PackageManagement.Cmdlets.CmdletBase.SelectProviders(String name)
at Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackageProvider.ProcessProvidersFilteredByName()
at Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackageProvider.ProcessRecordAsync()
at Microsoft.PowerShell.PackageManagement.Cmdlets.AsyncCmdlet.<>c__DisplayClass83_0.b__0()'
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7478 char:30

  • ... tProvider = PackageManagement\Get-PackageProvider -Name $script:NuGet ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (Microsoft.Power...PackageProvider:GetPackageProvider) [Get-PackageP
      rovider], Exception
    • FullyQualifiedErrorId : UnhandledException,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackageProvider

Install-Module : NuGet provider is required to interact with NuGet-based repositories. Please ensure that
'2.8.5.201' or newer version of NuGet provider is installed.
At line:1 char:1

  • Install-Module -Name Microsoft.WinGet.Client
  •   + CategoryInfo          : InvalidOperation: (:) [Install-Module], InvalidOperationException
      + FullyQualifiedErrorId : CouldNotInstallNuGetProvider,Install-Module
    
    

PS C:\WINDOWS\system32>

After this failure, subsequent commands confirm the provider is missing
Install-Module : NuGet provider is required to interact with NuGet-based repositories. Please ensure that
'2.8.5.201' or newer version of NuGet provider is installed.

Environment
[winget --info]
Windows Package Manager version: [Run `winget --info` and paste output here]
Windows: Windows.Desktop version [e.g., 10.0.19045.0]
Package: Microsoft.DesktopAppInstaller version [e.g., 1.22.x]

PowerShell Version: 5.1 (Windows PowerShell) / PowerShell 7.x
OS Architecture: x64
Vorherrschende Sprache
C++
Sterne
26.6k
Forks
1.8k
Ø Merge
3 T. 10 Std.
Gemergte PRs (30 T.)
41

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus microsoft/winget-cli

Alle Issues in microsoft/winget-cli

Ähnliche Issues

Weitere Issues zu C++

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.