简体   繁体   中英

Error when running msbuild /t:restore under Jenkins to restore nuget packages

The error we get during the build is:

Unable to load the service index for source https://api.nuget.org/v3/index.json.
An error occurred while sending the request.
The underlying connection was closed: An unexpected error occurred on a send.
Authentication failed because the remote party has closed the transport stream.

If I remote into the build machine and pull the source from source control, I can build and have VS restore the nuget packages without an issue.

I can also open https://api.nuget.org/v3/index.json in a browser on the machine, so I don't believe it's a network/firewall issue.

Note that Jenkins is running under SYSTEM LOCAL

The issue seems to have had to do with Win7 having TLS 1.2 disabled. Ran this on the machine and the error stopped:

reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v DisabledByDefault /t REG_DWORD /d 0 /f /reg:32
reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v DisabledByDefault /t REG_DWORD /d 0 /f /reg:64
reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v Enabled /t REG_DWORD /d 1 /f /reg:32
reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v Enabled /t REG_DWORD /d 1 /f /reg:64

Note that I think you need to add to both 32 and 64 bit registries because msbuild may run in either one depending on the build

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM