Mik*_*ynn 171 powershell powershell-2.0 nuget nuget-package visual-studio-2013
突然之间,升级Nuget软件包时出现此错误.我遇到过的修复工作都没有.我正在使用Visual Studio 2013.
已经安装了"Newtonsoft.Json 6.0.3".
将"Newtonsoft.Json 6.0.3"添加到Tournaments.Notifications中.
成功将"Newtonsoft.Json 6.0.3"添加到Tournaments.Notifications中.
执行脚本文件'F:\ My Webs\BasketballTournaments\MainBranch\packages\Newtonsoft.Json.6.0.3\tools\install.ps1'.
无法初始化PowerShell主机.如果PowerShell执行策略设置设置为AllSigned,请打开程序包管理器控制台以首先初始化主机.
包管理器控制台
尝试在"FileSystem"提供程序上执行InitializeDefaultDrives操作失败.
如果我等待初始化在控制台中完成,我可以添加一些包.
小智 192
将执行策略设置为RemoteSigned或Unrestricted应该有效.必须通过PowerShell控制台在管理员模式下进行更改.请注意,将根据PowerShell控制台的位版本应用更改,因此32位或64位.因此,如果要在Visual Studio(32位版本)中安装需要特定策略的软件包,则应通过PowerShell(x86)更改策略的设置.
PowerShell中的命令(作为管理员)将策略设置为不受限制(如评论中@Gabriel所述):
start-job { Set-ExecutionPolicy Unrestricted } -RunAs32 | wait-job | Receive-Job
Run Code Online (Sandbox Code Playgroud)
将策略设置为不受限制后,您将需要在安装完成后将策略设置回原始策略.
Sir*_*lih 55
Set-ExecutionPolicy Unrestricted在PowerShell(x86)中完成后,请记住重新启动Visual Studio .
如果这不起作用,请尝试Set-ExecutionPolicy RemoteSigned使用PowerShell(x86),然后重新启动Visual Studio.
Mic*_*der 51
默认情况下,出于安全原因,PowerShell脚本执行非常有限.要在NuGet中使用,我们需要打开门.
1.步骤
打开Windows PowerShell,运行为Administrator
2.步骤
NuGet正在使用32位控制台,因此它不会受到64位控制台更改的影响.运行以下脚本以确保您正在配置32位控制台.
start-job { Set-ExecutionPolicy RemoteSigned } -RunAs32 | wait-job | Receive-Job
Run Code Online (Sandbox Code Playgroud)
3.步骤
重新开始 Visual Studio
All*_*lan 25
我在Manage NuGet Packages对话框中遇到了同样的问题,我使用了一个可以帮助其他人的解决方法 - 从包管理器控制台运行:
如果我使用命令行powershell命令行安装包,一切都很好.
我不喜欢改变安全设置"只是为了让它工作".
Tro*_*ers 24
没有答案对我有用.
所有策略都是正确的但我在安装软件包时遇到错误
无法初始化PowerShell主机.如果PowerShell执行策略设置设置为AllSigned,请打开程序包管理器控制台以首先初始化主机.
该解决方案:我已经卸载了NuGet包管理器插件,并重新安装它.
小智 6
最近我开始用6.0.4开始,我不认为这是一个非常好的解决方案,但这对我有帮助.关闭Visual Studio
小智 6
如果以上答案对您有用 -
升级到Windows 10后,我遇到了同样的问题.
这对我有用
Set-ExecutionPolicy Unrestricted如果仍然无效,请尝试编辑 devenv.exe.config
Visual Studio 2013: C:\Users\<UserName>\AppData\Local\Microsoft\VisualStudio\12.0
Visual Studio 2015: C:\Users\<UserName>\AppData\Local\Microsoft\VisualStudio\14.0
添加以下内容
<dependentAssembly>
<assemblyIdentity name="System.Management.Automation" publicKeyToken="31bf3856ad364e35" />
<publisherPolicy apply="no" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.PowerShell.Commands.Utility" publicKeyToken="31bf3856ad364e35" />
<publisherPolicy apply="no" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.PowerShell.ConsoleHost" publicKeyToken="31bf3856ad364e35" />
<publisherPolicy apply="no" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.PowerShell.Commands.Management" publicKeyToken="31bf3856ad364e35" />
<publisherPolicy apply="no" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.PowerShell.Security" publicKeyToken="31bf3856ad364e35" />
<publisherPolicy apply="no" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.PowerShell.Commands.Diagnostics" publicKeyToken="31bf3856ad364e35" />
<publisherPolicy apply="no" />
</dependentAssembly>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
98051 次 |
| 最近记录: |