oneget: error trying to install package provider (for powershell core)
I am having packaging problems with powershell core, so I submitted https://github.com/PowerShell/PowerShell/issues/10867. But @iSazonov re-directed me to oneget. I am completely lost as to what is wrong, but I thought I would let you know. Perhaps the most fundamental problem is with get-packageprovider:
PS C:\Users\e27290> gcm get-packageprovider
CommandType Name Version Source
----------- ---- ------- ------
Cmdlet Get-PackageProvider 1.0.0.1 PackageManagement
But when I run it, I get this error:
PS C:\Users\e27290> get-packageprovider
get-packageprovider : Unhandled Exception - Message:'The type initializer for 'Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicType' threw an exception.' Name:'TypeInitializationException' Stack Trace:' at Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicType.Create(Type tInterface, OrderedDictionary`2 instanceMethods, List`2 delegateMethods, List`1 stubMethods, List`2 usedInstances)
at Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicInterface.CreateProxy(Type tInterface, Object[] instances)
at Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicInterface.DynamicCast(Type tInterface, Object[] instances)
at Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicInterface.DynamicCast[TInterface](Object[] instances)
at Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicInterfaceExtensions.As[TInterface](Object instance)
at Microsoft.PowerShell.PackageManagement.Cmdlets.CmdletBase.get_PackageManagementHost()
at Microsoft.PowerShell.PackageManagement.Cmdlets.CmdletBase.SelectProviders(String[] names)
at Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackageProvider.ProcessRecordAsync()
at Microsoft.PowerShell.PackageManagement.Cmdlets.AsyncCmdlet.<>c__DisplayClass83_0.<AsyncRun>b__0()'
At line:1 char:1
+ get-packageprovider
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.PowerShel\u2026.GetPackageProvider:GetPackageProvider) [Get-PackageProvider], Exception
+ FullyQualifiedErrorId : UnhandledException,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackageProvider
This seems to be a powershell core problem not a oneget problem. (I do not have these problems with powershell.)
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 36
This lead me in the direction of fixing this problem for me in 7.2.5. $env:PSModulePath had “C:\Program Files\WindowsPowerShell\Modules” before “C:\Program Files\PowerShell\7\Modules”. When I made the v7 path the first item I was able to install modules again.
Strangely, attempting to Update-Module PackageManagement reports an issue, but otherwise I experience no issues.
PS Version: 7.2.2 Same problem.
This was a bug fixed in PowerShell 7.1. See https://github.com/PowerShell/PowerShell/pull/12203
I may be able to prepare for you small .NET Core (.NET 7) WinForms powered app with powershell (core) inside with 3 rows of Powershell. It is small part of bigger applications installing IIS, url rewrite etc on WinServer 2016/2019 so we need to get nuget provider there
Same problem in 7.2.3 too. I see it in both Windows powershell and powershell core.
I am trying to update DBATOOLS module and get this…
If I run
Get-PackageProvider -ListAvailablethough, I see that nuget is already installed…I found this: https://github.com/PowerShell/PowerShellGetv2/issues/605
I’ve been checking in on this issue for a while and finally have a workaround that worked on my machine. Just run this in Core: