mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-20 06:29:50 +00:00
* Add install of dotnet tools - Add new section under dotnet. - Add installer for dotnet tools. - Add tests for dotnet tools. - Add dotnet tools to software report. * Fixes from code review * Add test and version check to dotnet tool json - Rework installer to use tool name. - Rework test to call tool test. - Rework software report to use tool specific command to get version. * Fixes from code review * Fix test for nbgv * Fix linux installer * Fix name for test context. * Update images/linux/scripts/installers/dotnetcore-sdk.sh Co-authored-by: PJ <me@panekj.dev> * Update images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 Co-authored-by: PJ <me@panekj.dev> * Update images/win/scripts/Tests/DotnetSDK.Tests.ps1 Co-authored-by: PJ <me@panekj.dev> * Aligning PS1 between win and linux * Remove out * Add Nuget.org as feed source for installing tool * Fix tests * Fix getting tool version * Change from code review * Update images/win/toolsets/toolset-2022.json Co-authored-by: Mikhail Timofeev <48208649+miketimofeev@users.noreply.github.com> * Update images/win/toolsets/toolset-2019.json Co-authored-by: Mikhail Timofeev <48208649+miketimofeev@users.noreply.github.com> * Update images/win/toolsets/toolset-2016.json Co-authored-by: Mikhail Timofeev <48208649+miketimofeev@users.noreply.github.com> * Changes from code review * Change from code revision * Fix tests * dotnet tool is now installed to a tool path * Move dotnet tools install - Need to install the dotnet tools AFTER post install steps otherwise dotnet is not in the path. * Fxi typo in path * Add path to software report for dotnet tools * Remove new line (from code review) * Add progress output message to dotnet tools install * Change install path for tool * New updating PATH with dotnet tools location * Remove duplicated assigment * Remove output message and add back Out-null Co-authored-by: PJ <me@panekj.dev> Co-authored-by: Mikhail Timofeev <48208649+miketimofeev@users.noreply.github.com>
78 lines
3.1 KiB
Bash
78 lines
3.1 KiB
Bash
#!/bin/bash -e
|
|
################################################################################
|
|
## File: dotnetcore-sdk.sh
|
|
## Desc: Installs .NET Core SDK
|
|
################################################################################
|
|
|
|
source $HELPER_SCRIPTS/etc-environment.sh
|
|
source $HELPER_SCRIPTS/install.sh
|
|
source $HELPER_SCRIPTS/os.sh
|
|
|
|
# Ubuntu 20 doesn't support EOL versions
|
|
LATEST_DOTNET_PACKAGES=$(get_toolset_value '.dotnet.aptPackages[]')
|
|
DOTNET_VERSIONS=$(get_toolset_value '.dotnet.versions[]')
|
|
DOTNET_TOOLS=$(get_toolset_value '.dotnet.tools[].name')
|
|
|
|
# Disable telemetry
|
|
export DOTNET_CLI_TELEMETRY_OPTOUT=1
|
|
|
|
for latest_package in ${LATEST_DOTNET_PACKAGES[@]}; do
|
|
echo "Determing if .NET Core ($latest_package) is installed"
|
|
if ! IsPackageInstalled $latest_package; then
|
|
echo "Could not find .NET Core ($latest_package), installing..."
|
|
apt-get install $latest_package -y
|
|
else
|
|
echo ".NET Core ($latest_package) is already installed"
|
|
fi
|
|
done
|
|
|
|
# Get list of all released SDKs from channels which are not end-of-life or preview
|
|
sdks=()
|
|
for version in ${DOTNET_VERSIONS[@]}; do
|
|
release_url="https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/${version}/releases.json"
|
|
download_with_retries "${release_url}" "." "${version}.json"
|
|
releases=$(cat "./${version}.json")
|
|
sdks=("${sdks[@]}" $(echo "${releases}" | jq '.releases[]' | jq '.sdk.version'))
|
|
sdks=("${sdks[@]}" $(echo "${releases}" | jq '.releases[]' | jq '.sdks[]?' | jq '.version'))
|
|
rm ./${version}.json
|
|
done
|
|
|
|
sortedSdks=$(echo ${sdks[@]} | tr ' ' '\n' | grep -v preview | grep -v rc | grep -v display | cut -d\" -f2 | sort -r | uniq -w 5)
|
|
|
|
extract_dotnet_sdk() {
|
|
local ARCHIVE_NAME="$1"
|
|
set -e
|
|
dest="./tmp-$(basename -s .tar.gz $ARCHIVE_NAME)"
|
|
echo "Extracting $ARCHIVE_NAME to $dest"
|
|
mkdir "$dest" && tar -C "$dest" -xzf "$ARCHIVE_NAME"
|
|
rsync -qav --remove-source-files "$dest/shared/" /usr/share/dotnet/shared/
|
|
rsync -qav --remove-source-files "$dest/host/" /usr/share/dotnet/host/
|
|
rsync -qav --remove-source-files "$dest/sdk/" /usr/share/dotnet/sdk/
|
|
rm -rf "$dest" "$ARCHIVE_NAME"
|
|
}
|
|
|
|
# Download/install additional SDKs in parallel
|
|
export -f download_with_retries
|
|
export -f extract_dotnet_sdk
|
|
|
|
parallel --jobs 0 --halt soon,fail=1 \
|
|
'url="https://dotnetcli.blob.core.windows.net/dotnet/Sdk/{}/dotnet-sdk-{}-linux-x64.tar.gz"; \
|
|
download_with_retries $url' ::: "${sortedSdks[@]}"
|
|
|
|
find . -name "*.tar.gz" | parallel --halt soon,fail=1 'extract_dotnet_sdk {}'
|
|
|
|
# NuGetFallbackFolder at /usr/share/dotnet/sdk/NuGetFallbackFolder is warmed up by smoke test
|
|
# Additional FTE will just copy to ~/.dotnet/NuGet which provides no benefit on a fungible machine
|
|
setEtcEnvironmentVariable DOTNET_SKIP_FIRST_TIME_EXPERIENCE 1
|
|
setEtcEnvironmentVariable DOTNET_NOLOGO 1
|
|
setEtcEnvironmentVariable DOTNET_MULTILEVEL_LOOKUP 0
|
|
prependEtcEnvironmentPath '$HOME/.dotnet/tools'
|
|
|
|
# install dotnet tools
|
|
for dotnet_tool in ${DOTNET_TOOLS[@]}; do
|
|
echo "Installing dotnet tool $dotnet_tool"
|
|
dotnet tool install $dotnet_tool --tool-path '/etc/skel/.dotnet/tools'
|
|
done
|
|
|
|
invoke_tests "DotnetSDK"
|