第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 output:
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser Unrestricted
LocalMachine Unrestricted
NuGet包本身或我的系统有问题吗?
在搜索解决方案之前和之后我都没有遇到过这个问题(到目前为止没有找到) - 我受NuGet / Visual Studio众神的支配!
提前致谢。
==
第2天:上午8:00 ......
再次尝试...让我们看看我们是否可以让Package Manager控制台正常工作......
启动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 Installer ......
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 Installer
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支蜡烛并高呼#34; 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
放弃......
结果:
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社区也没有解决这个问题!!!!
==
第4天 - 上午9:11
昨晚我在GitHub上重新开启了一个新问题,请参阅:
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主机的根本原因尚未解决。
如果有人找到根本原因,请发布您的解决方案。
答案 0 :(得分:2)
答案 1 :(得分:0)
我们最终确定了问题的根本原因,并将在15.8版本的Visual Studio中修复。
目前,可能的解决方法是:
1)在您的计算机上安装.NET 2.0,它将安装System.Management.Automation Version = 1.0.0
2)使用devenv.exe.config中社区的一些成员建议的绑定重定向:
<dependentAssembly>
<assemblyIdentity name="System.Management.Automation" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
<publisherPolicy apply="no" />
</dependentAssembly>
谢谢, Rohit Agrawal NuGet团队