Visual Studio 2019 更新中断发布(不正确的 TLS 版本)

Posted

技术标签:

【中文标题】Visual Studio 2019 更新中断发布(不正确的 TLS 版本)【英文标题】:Visual Studio 2019 update breaks publishing (incorrect TLS version) 【发布时间】:2020-08-26 11:21:35 【问题描述】:

短版

如何更改用于获取依赖项的 Visual Studio 2019 的默认 TLS 版本?

加长版

截至 Visual Studio 2019 v16.7.1(最新的 v16.7.2 未解决此问题)我似乎无法发布任何 dotnet 核心项目。发布操作总是崩溃并显示以下消息:

Publish has encountered an error.
Publish has encountered an error. We were unable to determine the cause of the error.
Check the output log for more details.

看一下输出窗口:

可以看出,VS 似乎无法建立与 nuget 的 TLS 连接。 在发布时使用 Wireshark 进行监控的进一步调查揭示了这一点:

可以清楚地看到,由于 TLS 版本不正确,连接失败。 Visual Studio 似乎使用了 nuget api 不支持的TLSv1。我们还可以看到 VS 正在重试几次,因此数据包数量很大。

使用我的网络浏览器手动连接到https://api.nuget.org/v3/index.json 表明 nuget.org 实际上使用了TLSv1.2

所以我的问题是:如何告诉 Visual Studio 使用 TLSv1.2 而不是 TLSv1 连接到 nuget.org?或者有可能吗?是否有用于此的 Windows 注册表项?

我还没有尝试重新安装 VS,但如果可能的话,我想避免这样做。

【问题讨论】:

你有什么操作系统?问题可能出在您的操作系统上。 我正在运行 Windows 7 Ultimate。虽然过去没有遇到任何问题:| 您可以尝试在您的操作系统设置中取消选中Internet Options -> Advanced 下的Use TLS 1.0 选项吗? 取消勾选,重启,VS 仍在使用 TLS 1.0 :( make the changes to registry,重启看看能否解决你的问题 【参考方案1】:

正如在 cmets 中指出的那样,设置以下注册表项:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp\
      DefaultSecureProtocols = (DWORD): 0xAA0
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Internet Settings\WinHttp\
      DefaultSecureProtocols = (DWORD): 0xAA0

(更多文档 here 和 here) 结合在 Windows 7 控制面板中取消选中 Internet Options -> Advanced 下的 Use TLS 1.0 选项就可以了。

【讨论】:

以上是关于Visual Studio 2019 更新中断发布(不正确的 TLS 版本)的主要内容,如果未能解决你的问题,请参考以下文章

允许此预编译站点可更新 Visual Studio 2019

在 Visual Studio 2019 中使用的 Razor 视图未更新

Xamarin Forms - 从 2017 年到 2019 年更新 Visual Studio 后 iOS 上的奇怪行为

更新到 2020 年 5 月版本后无法在 Visual Studio 2019 中创建 .exe 文件

最强IDE,微软宣布Visual Studio 2019

调试时 Visual Studio 2019 未启动控制台应用程序窗口