因为公司的NUGET服务器需要VPN才能连接,而最近公司的VPN出了点问题。 连接不同的资源要用不同的VPN, 而我又没办法同时运行多个VPN。 于是我在公司的电脑上运行一台虚拟机, 虚拟机里连接VPN, 然后在虚拟机里运行Fiddler做代理。 这样我就可以用这个代理来连接 NUGET。物理机上则连接另一个VPN。
首先要加上 disableTLSCertificateValidation=”True”
nuget.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<disabledPackageSources>
<clear />
</disabledPackageSources>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" disableTLSCertificateValidation="True"/>
<add key="pharos" value="https://packages.devops.aws.pharos.com/nuget/pharosfeed/v3/index.json" disableTLSCertificateValidation="True"/>
</packageSources>
</configuration>
然后在命令行输入
export http_proxy=http://10.0.2.132;dotnet restore
我发现在 nuget.config 直接设置代理不能工作, 而设置环境变量 http_proxy 就能成功。