Files
runner-images/images/ubuntu/scripts/build/install-dotnetcore-sdk.sh
T

77 lines
2.5 KiB
Bash
Raw Normal View History

2020-10-07 13:49:40 +05:00
#!/bin/bash -e
2019-11-15 15:23:41 -05:00
################################################################################
2023-11-22 21:49:23 +01:00
## File: install-dotnetcore-sdk.sh
## Desc: Install .NET Core SDK
2019-11-15 15:23:41 -05:00
################################################################################
2020-07-08 22:28:23 +03:00
2023-12-29 12:36:27 +01:00
# Source the helpers for use with the script
source $HELPER_SCRIPTS/etc-environment.sh
2020-07-08 22:28:23 +03:00
source $HELPER_SCRIPTS/install.sh
+15
2020-05-26 18:45:48 +03:00
source $HELPER_SCRIPTS/os.sh
2019-11-15 15:23:41 -05:00
2023-12-29 12:36:27 +01:00
dotnet_versions=$(get_toolset_value '.dotnet.versions[]')
dotnet_tools=$(get_toolset_value '.dotnet.tools[].name')
2019-11-15 15:23:41 -05:00
# Disable telemetry
export DOTNET_CLI_TELEMETRY_OPTOUT=1
# Install dotnet dependencies
# https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu-decision#dependencies
apt-get update
apt-get install --no-install-recommends \
ca-certificates \
libc6 \
libgcc-s1 \
libgssapi-krb5-2 \
liblttng-ust1 \
libssl3 \
libstdc++6 \
zlib1g
if is_ubuntu22; then
apt-get install --no-install-recommends libicu70
fi
2019-11-15 15:23:41 -05:00
if is_ubuntu24; then
apt-get install --no-install-recommends libicu74
fi
# Install .NET SDKs and Runtimes
mkdir -p /usr/share/dotnet
2019-11-15 15:23:41 -05:00
sdks=()
2023-12-29 12:36:27 +01:00
for version in ${dotnet_versions[@]}; do
2020-11-05 19:35:43 +03:00
release_url="https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/${version}/releases.json"
releases=$(cat "$(download_with_retry "$release_url")")
sdks=("${sdks[@]}" $(echo "${releases}" | jq -r '.releases[].sdk.version | select(contains("preview") or contains("rc") | not)'))
sdks=("${sdks[@]}" $(echo "${releases}" | jq -r '.releases[].sdks[]?.version | select(contains("preview") or contains("rc") | not)'))
2019-11-15 15:23:41 -05:00
done
2023-12-29 12:36:27 +01:00
sorted_sdks=$(echo ${sdks[@]} | tr ' ' '\n' | sort -r | uniq -w 5)
2019-11-15 15:23:41 -05:00
## Download installer from dot.net
DOTNET_INSTALL_SCRIPT="https://dot.net/v1/dotnet-install.sh"
install_script_path=$(download_with_retry $DOTNET_INSTALL_SCRIPT)
chmod +x $install_script_path
2019-11-15 15:23:41 -05:00
for sdk in ${sorted_sdks[@]}; do
echo "Installing .NET SDK $sdk"
$install_script_path --version $sdk --install-dir /usr/share/dotnet --no-path
done
## Dotnet installer doesn't create symlinks to executable or modify PATH
ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
2019-11-15 15:23:41 -05:00
2023-12-26 12:50:52 +01:00
set_etc_environment_variable DOTNET_SKIP_FIRST_TIME_EXPERIENCE 1
set_etc_environment_variable DOTNET_NOLOGO 1
set_etc_environment_variable DOTNET_MULTILEVEL_LOOKUP 0
prepend_etc_environment_path '$HOME/.dotnet/tools'
2023-12-29 12:36:27 +01:00
# Install .Net tools
for dotnet_tool in ${dotnet_tools[@]}; do
2022-01-18 13:31:51 +00:00
echo "Installing dotnet tool $dotnet_tool"
dotnet tool install $dotnet_tool --tool-path '/etc/skel/.dotnet/tools'
done
invoke_tests "DotnetSDK"