.netpowershelljenkinsbuildcakebuild

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


I am facing an issue when trying to run build cake file in powershell.

enter image description here

Here is the link with the full script

This is the same for Jenkins and as localhost.

In the response I see those lines too: Downloading and installing Roslyn... Installing packages (using https://packages.nuget.org/api/v2)...

I am not sure if Roslyn requires this dowload, or the step that informs Downloading and installing Roslyn... it is already over and Installing packages is the next step.

I tried updating the cake and semver version. And it runs ok:

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>

But in the result of build, I do not see, for example, "Downloading and installing Roslyn...", so I am not sure if it worked properly: enter image description here

enter image description here

Thank you for your help


Solution

  • Can you please confirm if your build.ps1 file contains the following lines of code:

    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 has turned off TLS 1.0 and 1.1, and you will not be able to download any packages from NuGet.org unless a change is made similar to the above. More details can be found here:

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

    The need to download the Roslyn components was removed in this PR:

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

    Which shipped in version v0.22.0 of Cake. As a result, you won't see the messaging about downloading Roslyn in newer versions of Cake.

    With regard to the version of Cake that you are using, 0.21.1, this shipped over 3 years ago:

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

    Unless there is a compelling reason to stay using this version, I would recommend that you switch to using the latest.