配置 Visual Studio 使用指定的代理服务器访问网络

1、首先找到 Visual Studio 主程序文件 devenv.exe 所在的文件夹

如:Visual Studio 2022 的默认安装路径为:C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\devenv.exe

2、在同文件夹内找到 devenv.exe.config 配置文件,打开进行编辑(需要管理员权限进行保存)

3、找到 configuration / system.net 结点,添加以下配置:

复制代码
  <configuration>
    <system.net>
      <!-- 这部分是原有配置 -->
      <settings>
        <ipv6 enabled="true"/>
      </settings>
      <!-- 这部分是新增代理配置,请根据实际情况修改地址 -->
      <defaultProxy>  
        <proxy proxyaddress="http://127.0.0.1:8080" bypassonlocal="true" />
      </defaultProxy>
    </system.net>
  </configuration>
复制代码

4、配置保存后,记得重启 Visual Studio,并在以后不使用代理时记得还原!

参考来源:https://www.cnblogs.com/shiningrise/p/5491899.html

更多资料:https://learn.microsoft.com/zh-cn/dotnet/framework/configure-apps/file-schema/network/defaultproxy-element-network-settings

5、后来发现为 Visual Studio 配置代理后,会导致内置 nuget 包管理器不能正常使用,会报以下错误:

ServicePointManager 不支持具有 https 方案的代理

6、需要单独再为 nuget 配置代理可解决此问题

打开 %AppData%\NuGet\NuGet.config 文件

在 configuration 中,修改增加配置:

<configuration>
  <!-- 这部分是新增代理配置,请根据实际情况修改地址 -->
  <config>
    <add key="HTTP_PROXY" value="http://127.0.0.1:8080" />
  </config>
</configuration>

7、保存后重启 Visual Studio 即可恢复正常,同样记得不用时要还原哦!

参考来源:https://stackoverflow.com/a/38400511

posted @   不是豆豆  阅读(3985)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
友情链接:迷途


点击右上角即可分享
微信分享提示