Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 57dc0ab

Browse files
committed
Fix NuGet.exe package restore on systems where wget fails because of missing CA-trust.
Trying to run `build.sh` on a clean FreeBSD-system will fail because NuGet.exe isn't downloaded correctly. ```` /usr/home/josteink/build/corefx $ wget https://api.nuget.org/downloads/nuget.exe --2015-06-21 05:43:58-- https://api.nuget.org/downloads/nuget.exe Resolving api.nuget.org (api.nuget.org)... 185.31.18.64 Connecting to api.nuget.org (api.nuget.org)|185.31.18.64|:443... connected. ERROR: cannot verify api.nuget.org's certificate, issued by ‘CN=DigiCert SHA2 High Assurance Server CA,OU=www.digicert.com,O=DigiCert Inc,C=US’: Unable to locally verify the issuer's authority. To connect to api.nuget.org insecurely, use `--no-check-certificate'. /usr/home/josteink/build/corefx $ ```` This is the case on a default FreeBSD 10.1 installation, and the same behaviour with wget failing on HTTPS trust-issues can very often be observed in the wild across several OSes and projects, not just FreeBSD and corefx. (For FreeBSD, a workaround for this issue is to install the `/usr/ports/security/ca_root_nss`, but this package is not installed by default.) After this error has (silently) happened, a zero-byte NuGet.exe is left on disk, causing all subsequent builds to fail on the MSbuild-restore stage. Downloading with curl however doesn't fail, so default to trying curl instead of wget first solves this issue.
1 parent 4b4b862 commit 57dc0ab

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

build.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ if [ ! -e "$__nugetpath" ]; then
5050
fi
5151
echo "Restoring NuGet.exe..."
5252

53-
which wget > /dev/null 2> /dev/null
53+
# curl has HTTPS CA trust-issues less often than wget, so lets try that first.
54+
which curl > /dev/null 2> /dev/null
5455
if [ $? -ne 0 ]; then
55-
curl -sSL --create-dirs -o $__nugetpath https://api.nuget.org/downloads/nuget.exe
56-
else
5756
mkdir -p $__packageroot
5857
wget -q -O $__nugetpath https://api.nuget.org/downloads/nuget.exe
58+
else
59+
curl -sSL --create-dirs -o $__nugetpath https://api.nuget.org/downloads/nuget.exe
5960
fi
6061

6162
if [ $? -ne 0 ]; then

0 commit comments

Comments
 (0)