Files
runner-images/images/macos/provision/core/dotnet.sh
Aleksandr Chebotov caa7a1ac6d [macOS] Get rid of invoke_tests imports (#2496)
* get rid of invoke_tests imports

* add sudo

* change path to /usr/bin/invoke_tests

* create /usr/local/bin dir

* remove local variables

* fix group owner

* set default 775 perm

* delete invoke_tests symlink
2021-01-22 09:26:28 +03:00

60 lines
2.1 KiB
Bash
Executable File

#!/bin/bash -e -o pipefail
###########################################################################
# The main idea of this script is to automate dotnet installs
# Based on:
# https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-install-script
#
###########################################################################
source ~/utils/utils.sh
export DOTNET_CLI_TELEMETRY_OPTOUT=1
# Download installer from dot.net and keep it locally
DOTNET_INSTALL_SCRIPT="https://dotnet.microsoft.com/download/dotnet-core/scripts/v1/dotnet-install.sh"
curl -o "dotnet-install.sh" "$DOTNET_INSTALL_SCRIPT"
chmod +x ./dotnet-install.sh
ARGS_LIST=()
echo "Parsing dotnet SDK (except rc and preview versions) from .json..."
DOTNET_VERSIONS=($(get_toolset_value '.dotnet.versions | .[]'))
for DOTNET_VERSION in "${DOTNET_VERSIONS[@]}"; do
RELEASE_URL="https://raw.githubusercontent.com/dotnet/core/master/release-notes/${DOTNET_VERSION}/releases.json"
# Old Mono versions don't support NuGet versions from .Net sdk >=2.1.6**, exclude them explicitly from Mojave and HS images
# https://rider-support.jetbrains.com/hc/en-us/articles/360004180039
if is_Less_Catalina; then
ARGS_LIST+=(
$(curl -s "$RELEASE_URL" | \
jq -r '.releases[].sdk."version"' | grep -v -E '\-(preview|rc)\d*' | grep -v -E '2.1.[6-9]\d*')
)
else
ARGS_LIST+=(
$(curl -s "$RELEASE_URL" | \
jq -r '.releases[].sdk."version"' | grep -v -E '\-(preview|rc)\d*')
)
fi
done
for ARGS in "${ARGS_LIST[@]}"; do
./dotnet-install.sh --version $ARGS -NoPath
done
rm ./dotnet-install.sh
# dotnet installer doesn't create symlink to executable in /user/local/bin
# Moreover at that moment /user/local/bin doesn't exist (though already added to $PATH)
ln -s ~/.dotnet/dotnet /usr/local/bin/dotnet
# Validate installation
if [ $(dotnet --list-sdks | wc -l) -lt "1" ]; then
echo "The .NET Core SDK is not installed"
exit 1
fi
echo 'export PATH="$PATH:$HOME/.dotnet/tools"' >> "$HOME/.bashrc"
echo "Dotnet operations have been completed successfully..."
invoke_tests "Common" ".NET"