【发布时间】:2018-04-28 01:37:20
【问题描述】:
第 1 天:
System: Windows 10
Microsoft Visual Studio Community 2017
Version 15.5.5
VisualStudio.15.Release/15.5.5+27130.2026
我有一个使用 WindowsAzure.Storage NuGet 包的网站项目。
在 Visual Studio 中,我执行以下操作:
Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution ...
系统显示有 2 个更新可用:
Newtonsoft.Json v10.0.3 (currently installed v9.0.1)
WindowsAzure.Storage v9.0 (currently installed v8.7)
我选择选中“选择所有包”复选框并单击“更新”按钮。
失败(以前从未发生过这种情况)!!
以下是从 Visual Studio 捕获的输出:
Retrieving package 'WindowsAzure.Storage 9.0.0' from 'nuget.org'.
...
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3007) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3014) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3021) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3028) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3035) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The term 'Get-ExecutionPolicy' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Install failed. Rolling back...
错误列表窗口显示:
Failed to initialize the PowerShell host. If your PowerShell execution policy setting is set to AllSigned, open the Package Manager Console to initialize the host first.
Powershell 输出来自:Get-ExecutionPolicy -List 输出:
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Unrestricted
LocalMachine Unrestricted
NuGet 包本身或我的系统是否有问题?
在寻找解决方案之前和之后我从来没有遇到过这个问题(目前还没有找到)——我受制于 NuGet / Visual Studio 之神!
提前致谢。
======
第 2 天:上午 8:00 ...
再试一次......让我们看看我们是否可以让包管理器控制台工作......
启动 Visual Studio(社区 2017)
TOOLS -> NuGet Package Manager -> Package Manager Console
这会导致显示以下内容:
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3007) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3014) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3021) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3028) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3035) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The term 'Get-ExecutionPolicy' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
回到绘图板!将继续寻找解决方案...
那么,让我们试试 Visual Studio 安装程序...
Launch Visual Studio Installer
Select "More" -> "Repair"
结果:
The dependent package cannot be found: Component.PowerShellTools.VS2017,version=3.0.585
我点击“查看日志”,显示:
[1cb4:000a][2018-02-17T08:27:06] Error 0x80131500: The dependent package cannot be found: Component.PowerShellTools.VS2017,version=3.0.585
at Microsoft.VisualStudio.Setup.Dependencies.DependencyManager.FindDependentPackages(Dependency dependency, DependencyComparer comparer, Dictionary`2 packageIndex)
at Microsoft.VisualStudio.Setup.Dependencies.DependencyManager.BuildGraphRecursive(IPackage graphRoot, DependencyNode node, DependencyComparer comparer, Dictionary`2 packageIndex, Dictionary`2 nodeIndex, Boolean splitNodes)
at Microsoft.VisualStudio.Setup.Dependencies.DependencyManager.BuildGraphCore(IPackage root, IEnumerable`1 packages, DependencyComparer comparer, Dictionary`2 packageIndex, Dictionary`2 nodeIndex, Boolean splitNodes, DependencyCollection deprecated)
at Microsoft.VisualStudio.Setup.Dependencies.DependencyManager.BuildGraph(IPackage root, IEnumerable`1 packages, Boolean isUpdate, IDependencyComparisonSeed seed, DependencyCollection deprecated)
at Microsoft.VisualStudio.Setup.Engine.GetDependencyGraph(Product product)
at Microsoft.VisualStudio.Setup.Engine.PreChecks(String installationPath, Boolean isLayoutSet, Product product, ExecuteAction bootstrapperAction, ITelemetryOperation operation, IQuery query)
at Microsoft.VisualStudio.Setup.Engine.Repair(CancellationToken token)
好的 - 不知何故,我的系统丢失了一个依赖包 (Component.PowerShellTools.VS2017) - 将尝试修改以查看是否可以添加包...
======
第 2 天 - 上午 10:15(仍在进行中) - 当前状态 - 智慧结束...
Microsoft Visual Studio Community 2017
Version 15.5.6
VisualStudio.15.Release/15.5.6+27130.2027
Microsoft .NET Framework
Version 4.7.02556
我执行以下操作:
TOOLS -> NuGet Package Manager -> Package Manager Console
这会导致显示以下内容:
如果有人(微软)有解决方案——我将不胜感激!
======
第 2 天:下午 3:09 ...
在最后一次(绝望的)尝试中,我启动了 Visual Studio 安装程序
Click on "More" -> "Repair" ....
几个小时后,Visual Studio 被(重新)安装了:
Microsoft Visual Studio Community 2017
Version 15.5.6
VisualStudio.15.Release/15.5.6+27130.2027
Microsoft .NET Framework
Version 4.7.02556
然后我执行以下操作(点燃 12 支蜡烛并高呼“Bill-Bill-Bill”之后)...
TOOLS -> NuGet Package Manager -> NuGet Manager Console
结果:
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3007) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3014) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3021) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3028) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3035) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The term 'Get-ExecutionPolicy' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
我注定要失败 - 在此问题解决之前我无法使用 Visual Studio。
======
第 3 天 - 上午 7:49
我看到我的问题已被 MSFT 分类:
还尝试了这些资源中的“解决方案”:
很遗憾,以上方法均无助于纠正此问题。
大多数帖子都表明可能需要完全重新安装 VS —— 天哪!!
希望找到一个不需要完全重新安装的解决方案!
======
第 3 天 - 下午 1:54
放弃...
- 卸载 Visual Studio。关机(关闭系统)
- 启动(启动系统)
- 从下载的 Visual Studio 安装程序 https://www.visualstudio.com/downloads/
- 按照安装程序说明运行磁盘清理应用程序。
- 关机(系统断电)
- 启动(启动系统)
- 运行 Visual Studio 2017 社区安装程序 - 成功。
- 启动 Visual Studio
- 工具 -> NuGet 包管理器 -> 包管理器控制台
结果:
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3007) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3014) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3021) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3028) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The following error occurred while loading the extended type data file: Microsoft.PowerShell.Core, C:\Windows\SysWOW64\WindowsPowerShell\v1.0\types.ps1xml(3035) : Error in type "System.Security.AccessControl.ObjectSecurity": Exception: The getter method should be public, non void, static, and have one parameter of type PSObject.
The term 'Get-ExecutionPolicy' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
所以 - 即使是全新安装的 Visual Studio Community 也无法解决这个问题!!!!
======
第 4 天 - 上午 9:11
昨晚我在 GitHub re PowerShell 上打开了一个新问题,请参阅:
https://github.com/PowerShell/PowerShell/issues/6189
今天早上找到回复,采纳lzybkr的建议,禁用Powershell V2;我在上面的 GitHub 帖子上发布了禁用 V2 的命令。
好消息 - 我能够再次通过 NuGet 更新软件包!
坏消息 - 如果我启动 Visual Studio 然后:
TOOLS -> NuGet Package Manager -> Package Manager Console
控制台窗口打开,但只是挂起并显示以下消息:
Initializing Powershell host...
我仍然不知道是什么导致了 Visual Studio 中的这种行为;但 4 天后,我只是觉得自己很幸运,我可以(再次)更新 NuGet 包并重新开始工作。
虽然我更新 NuGet 包的“问题”(大部分)已经解决,但我仍然不认为这是一个解决方案,这是导致 Visual Studio / NuGet 包管理器控制台无法初始化 PowerShell 主机的根本原因未解决。
如果有人找到根本原因,请发布您的解决方案。
【问题讨论】:
-
我的同情。上周我经历了类似的考验——涉及 VS、Azure 和 NuGet 的多方版本控制 catch-22。我通读了你的问题,但似乎不是一回事。坦率地说,到最后我已经筋疲力尽了,我不确定我会得到多少帮助。
-
天哪!谢谢你的评论——看来我要去地狱了!顺便说一句 - 我刚刚将 Visual Studio 更新到 15.5.6 - 结果相同。啊!
-
我在磨难的中途也做了同样的升级。就我而言,这使事情变得更加复杂,因为您知道关于中途换马的说法。希望您的问题没有那么多活动部分。
标签: visual-studio powershell nuget-package