[英]Can't install nuget package provider in powershell core 6.2.0
我有天藍色的網絡作業。 我嘗試使用以下代碼將 Az 模塊安裝到 powershell core 6.2.0:
using (PowerShell ps = PowerShell.Create())
{
ps.Runspace = runspace;
ps.AddScript("Install-Module -Name Az -AllowClobber -Scope CurrentUser -
Force;");
}
但是在 azure webjob 控制台日志中,我收到關於安裝 nuget 包提供程序的錯誤。 然后我嘗試使用以下命令安裝 NuGet 包提供程序:
ps.AddScript("Install-PackageProvider -Name NuGet -MinimumVersion '2.8.5.201' -Force;");
但我收到以下錯誤:
[04/10/2019 15:54:00 > 674fe9: ERR] 未處理的異常:System.AggregateException:發生一個或多個錯誤。 (未處理的異常 - 消息:'Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicType' 的類型初始值設定項引發異常。' 名稱:'TypeInitializationException' 堆棧跟蹤:' 在 Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicType .Create(Type tInterface, OrderedDictionary
2 instanceMethods, List
2 delegateMethods, List1 stubMethods, List
2 usedInstances) [04/10/2019 15:54:00 > 674fe9: ERR ] at Microsoft.PackageManagement.Internal.Utility.Plugin.Plugin. .CreateProxy(Type tInterface, Object[] 實例) [04/10/2019 15:54:00 > 674fe9: ERR ] 在 Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicInterface.DynamicCast(Type tInterface, Object[] 實例) [04/10/2019 15:54:00 > 674fe9: ERR ] 在 Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicInterface.DynamicCast[TInterface](Object[] 實例) [04/10/2019 15:54:00 > 674fe9: ERR ] 在 Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicInterfaceExtensions.As[TInterface](Object ins tance) [04/10/2019 15:54:00 > 674fe9: ERR ] 在 Microsoft.PowerShell.PackageManagement.Cmdlets.CmdletBase.get_PackageManagementHost() [04/10/2019 15:54:00 > 674fe9] 在微軟:ERR .PowerShell.PackageManagement.Cmdlets.CmdletBase.SelectProviders(String[] names) [04/10/2019 15:54:00 > 674fe9: ERR ] 在 Microsoft.PowerShell.PackageManagement.Cmdlets.CmdletWithProvider.get_SelectedProviders() [04/10 /2019 15:54:00 > 674fe9: ERR ] 在 Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider.get_SelectedProviders() [04/10/2019 15:54:00 > 674fe9: ERR ] 在 Microsoft.PowerShell.PackageCmdlets.Cmdlets.InstallPackageProvider.get_SelectedProviders() .CmdletWithProvider.b__23_0() [04/10/2019 15:54:00 > 674fe9: ERR ] 在 Microsoft.PackageManagement.Internal.Utility.Extensions.DictionaryExtensions.GetOrAdd[TKey,TValue](IDictionary2 dictionary, TKey key, Func
Funcictionary2 dictionary, TKey key, Func
1 valueFunction) [04/10/2019 15:54:00 > 674fe9: ERR ] 在 Microsoft.PowerShell.PackageManagement.Cmdlets.CmdletWithProvider.get_CachedSelectedProviders() [04/10/2019 15:54:00 > 6 74fe9: ERR ] 在 Microsoft.PowerShell.PackageManagement.Cmdlets.CmdletWithProvider.GenerateDynamicParameters() [04/10/2019 15:54:00 > 674fe9: ERR ] 在 Microsoft.PowerShell.PackageManagement.Cmdlets.AsyncCmdlet_Display_Class80> ()') ---> System.Exception: Unhandled Exception - Message:''Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicType' 的類型初始值設定項引發異常。 名稱:'TypeInitializationException' 堆棧跟蹤:' 在 Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicType.Create(Type tInterface, OrderedDictionary2 instanceMethods, List
2 delegateMethods, List1 stubMethods, List
2 usedInstances) [04/10/2019 15 :54:00 > 674fe9: ERR ] 在 Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicInterface.CreateProxy(Type tInterface, Object[] 實例) [04/10/2019 15:54:00 > 674fe9: ERR] 在 Microsoft .PackageManagement.Internal.Utility.Plugin.DynamicInterface.DynamicCast(Type tInterface, Object[] 實例) [04/10/2019 15:54:00 > 674fe9: ERR ] 在 Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicInterface。 DynamicCast[TInterface](Object[] 實例) [04/10/2019 15:54:00 > 674fe9: ERR ] 在 Microsoft.PackageManagement.Internal.Utility.Plugin.DynamicInterfaceExtensions.As[TInterface](Object instance) [04/ 10/2019 15:54:00 > 674fe9: ERR ] 在 Microsoft.PowerShell.PackageManagement.Cmdlets.CmdletBase.get_PackageManagementHost() [04/10/2019 15:54:00 > 674fe9: ERR ] 在 Microsoft.PowerShell.PackageManagement.Cmdlets.CmdletBase.SelectProviders(String[] names) [04/10/2019 15:54:00 > 674fe9: ERR ] 在 Microsoft.PowerShell.PackageManagement .Cmdlets.CmdletWithProvider.get_SelectedProviders() [04/10/2019 15:54:00 > 674fe9: ERR ] 在 Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider.get_SelectedProviders() [04/10/2019:105 674fe9: ERR ] 在 Microsoft.PowerShell.PackageManagement.Cmdlets.CmdletWithProvider.b__23_0() [04/10/2019 15:54:00 > 674fe9: ERR ] 在 Microsoft.PackageManagement.Internal.Utility.Extensions.KeyExtensions.DictionaryExtensions.DictionaryExtensions ,TValue](IDictionary2 dictionary, TKey key, Func
1 valueFunction) [04/10/2019 15:54:00 > 674fe9: ERR ] 在 Microsoft.PowerShell.PackageManagement.Cmdlets.CmdletWithProvider.get_CachedSelectedProviders() [04/10 2019 年 15:54:00 > 674fe9: ERR ] 在 Microsoft.PowerShell.PackageManagement.Cmdlets.CmdletWithProvider.GenerateDynamicParameters() [04/10/2019 15:54:00 > 674fe9: ERR ] 在 Microsoft.PowerShell.PackageManagement.Cmdlets.AsyncCmdlet.<>c__DisplayClass83_0.b__0()'
它有什么問題? 如何將軟件包提供程序安裝到 powershell 核心? 或者如何在沒有 nuget 的情況下安裝 Az 模塊? 請幫忙)
這似乎也有效。 你試過這個選項嗎?
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
你也可以看看下面的文章,僅供參考。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.