今天是2024年11月21号,最近更新了VisualStudio后发现HTTP的包源已经默认禁止使用了,生成时会直接报错。如下图:

官方也明确指出了要想使用HTTP包源的解决办法,这里就简单总结一下。
一、全局配置
1、全局NuGet包的配置文件路径在
C:\Users\{账户名}\AppData\Roaming\NuGet
2、找到NuGet.Config文件并打开
3、在你的HTTP源节点后面加上**allowInsecureConnections="true"**即可

二、解决方案配置
1、在解决方案上右击->添加->新建项

2、新建XML文件,命名为Nuget.config

3、 在新建的文件中添加要使用的HTTP包源,并配置**allowInsecureConnections="true"**即可
XML
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget" value="http://你的源地址" allowInsecureConnections="true"/>
</packageSources>
</configuration>