Files
runner-images/images/macos/scripts/build/install-dotnet.sh
T

58 lines
1.9 KiB
Bash
Raw Normal View History

#!/bin/bash -e -o pipefail
2023-11-28 02:25:03 +01:00
################################################################################
## File: install-dotnet.sh
## Desc: Install dotnet
################################################################################
2020-09-10 14:34:08 +03:00
source ~/utils/utils.sh
export DOTNET_CLI_TELEMETRY_OPTOUT=1
arch=$(get_arch)
2020-09-10 14:34:08 +03:00
# Download installer from dot.net and keep it locally
DOTNET_INSTALL_SCRIPT="https://dot.net/v1/dotnet-install.sh"
install_script_path=$(download_with_retry $DOTNET_INSTALL_SCRIPT)
chmod +x $install_script_path
2020-09-10 14:34:08 +03:00
args_list=()
2020-09-10 14:34:08 +03:00
echo "Parsing dotnet SDK (except rc and preview versions) from .json..."
dotnet_versions=($(get_toolset_value ".dotnet.arch[\"$arch\"].versions | .[]"))
2020-09-10 14:34:08 +03:00
for dotnet_version in ${dotnet_versions[@]}; do
release_url="https://raw.githubusercontent.com/dotnet/core/main/release-notes/${dotnet_version}/releases.json"
releases_json_file=$(download_with_retry "$release_url")
2022-07-15 14:01:11 +02:00
if [[ $dotnet_version == "6.0" ]]; then
args_list+=(
$(cat $releases_json_file | jq -r 'first(.releases[].sdks[]?.version | select(contains("preview") or contains("rc") | not))')
2022-07-15 14:01:11 +02:00
)
else
args_list+=(
$(cat $releases_json_file | \
2022-07-15 14:01:11 +02:00
jq -r '.releases[].sdk."version"' | grep -v -E '\-(preview|rc)\d*' | \
sort -r | rev | uniq -s 2 | rev)
)
fi
2020-09-10 14:34:08 +03:00
done
for ARGS in ${args_list[@]}; do
$install_script_path --version $ARGS -NoPath --arch $arch
2020-09-10 14:34:08 +03:00
done
# 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
2020-09-10 14:34:08 +03:00
echo "The .NET Core SDK is not installed"
exit 1
fi
echo 'export PATH="$PATH:$HOME/.dotnet/tools"' >> $HOME/.bashrc
2020-09-10 14:34:08 +03:00
echo "Dotnet operations have been completed successfully..."
invoke_tests "Common" ".NET"