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

Visual Studio 2019 update breaks publishing (incorrect TLS version)

短版:

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

长版:

截至 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.

查看输出 window:

可以看出,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,但如果可能的话我想避免这样做。

正如评论中指出的那样,设置了以下注册表项:

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 and here) 结合 un-checking Internet Options 下的 Use TLS 1.0 选项 -> Windows 7 控制面板中的 Advanced 就可以了。