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

Abierto
#6,605 4 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
powershell
Área
cli

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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
Lenguaje dominante
C++
Estrellas
26.6k
Forks
1.8k
Merge medio
3 d 10 h
PR fusionados (30 d)
41

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de microsoft/winget-cli

Todos los issues de microsoft/winget-cli

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.