Cake.build error : "The underlying connection was closed: An unexpected error occurred on a send"

Cake.build error : "The underlying connection was closed: An unexpected error occurred on a send"

我在尝试 运行 在 powershell 中构建蛋糕文件时遇到问题。

这是 link 和 full script

这对于 Jenkins 和 localhost 是一样的。

在回复中我也看到了这些行: 下载并安装 Roslyn... 正在安装包(使用 https://packages.nuget.org/api/v2)...

我不确定 Roslyn 是否需要此下载,或通知下载和安装 Roslyn 的步骤...它已经结束,下一步是安装包。

我尝试更新 cake 和 semver 版本。 运行没问题:

build.cake
#addin "nuget:?package=Cake.SemVer&version=4.0.0"
#addin "nuget:?package=semver&version=2.0.6"

packages.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
    <package id="Cake" version="0.38.4" />
</packages>

但是在构建的结果中,我没有看到,例如,“正在下载和安装 Roslyn...”,所以我不确定它是否正常工作:

感谢您的帮助

请确认您的 build.ps1 文件是否包含以下代码行:

https://github.com/cake-build/resources/blob/master/build.ps1#L53-L68

# Attempt to set highest encryption available for SecurityProtocol.
# PowerShell will not set this by default (until maybe .NET 4.6.x). This
# will typically produce a message for PowerShell v2 (just an info
# message though)
try {
    # Set TLS 1.2 (3072), then TLS 1.1 (768), then TLS 1.0 (192), finally SSL 3.0 (48)
    # Use integers because the enumeration values for TLS 1.2 and TLS 1.1 won't
    # exist in .NET 4.0, even though they are addressable if .NET 4.5+ is
    # installed (.NET 4.5 is an in-place upgrade).
    # PowerShell Core already has support for TLS 1.2 so we can skip this if running in that.
    if (-not $IsCoreCLR) {
        [System.Net.ServicePointManager]::SecurityProtocol = 3072 -bor 768 -bor 192 -bor 48
    }
  } catch {
    Write-Output 'Unable to set PowerShell to use TLS 1.2 and TLS 1.1 due to old .NET Framework installed. If you see underlying connection closed or trust errors, you may need to upgrade to .NET Framework 4.5+ and PowerShell v3'
  }

NuGet 已关闭 TLS 1.0 和 1.1,您将无法从 NuGet.org 下载任何包,除非进行与上述类似的更改。可以在这里找到更多详细信息:

https://devblogs.microsoft.com/nuget/nuget-org-will-permanently-remove-support-for-tls-1-0-and-1-1-on-june-15th/

此 PR 中删除了下载 Roslyn 组件的需要:

https://github.com/cake-build/cake/pull/1645/files

在 Cake v0.22.0 版本中发布。因此,您不会在较新版本的 Cake 中看到有关下载 Roslyn 的消息。

关于您使用的 Cake 版本 0.21.1,这是 3 年前发布的:

https://www.nuget.org/packages/Cake/0.21.1

除非有令人信服的理由继续使用此版本,否则我建议您切换到使用最新版本。