问题
安装VS 2022创建一个 Web API 项目以后,执行 build 系统报告 build 失败原因是不能获取 https://api.nuget.org/v3/index.json。
按照网上的步骤把源换成:
https://nuget.cdn.azure.cn/v3/index.json
执行 dotnet restore 命令还是出现错误。
解决方案
给 nuget.config 文件增加代理,完美解决问题。亲测 socks5 代理也是可以的。nuget.config 的位置在:
C:\Users\your-username\AppData\Roaming\NuGet
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="https_proxy" value="http://172.26.198.222:1080" />
<add key="http_proxy" value="http://172.26.198.222:1080" />
</config>
</configuration>