From df51eabf531b57265be2b44eb4add62ee6a3cd70 Mon Sep 17 00:00:00 2001 From: panticmilos Date: Mon, 5 Sep 2022 13:18:26 +0200 Subject: [PATCH 1/2] Update package lock version --- package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 96c9134..6b6bff4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "setup-dotnet", - "version": "1.0.0", + "version": "2.1.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "setup-dotnet", - "version": "1.0.0", + "version": "2.1.0", "license": "MIT", "dependencies": { "@actions/core": "^1.6.0", From bba8299c353791dc1a458157c32af1cfd0c5a933 Mon Sep 17 00:00:00 2001 From: panticmilos Date: Wed, 14 Sep 2022 16:08:36 +0200 Subject: [PATCH 2/2] npm run update-installers --- externals/install-dotnet.sh | 48 ++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/externals/install-dotnet.sh b/externals/install-dotnet.sh index 55f4350..3e16cc9 100755 --- a/externals/install-dotnet.sh +++ b/externals/install-dotnet.sh @@ -353,6 +353,48 @@ get_normalized_architecture_from_architecture() { return 1 } +# args: +# version - $1 +# channel - $2 +# architecture - $3 +get_normalized_architecture_for_specific_sdk_version() { + eval $invocation + + local is_version_support_arm64="$(is_arm64_supported "$1")" + local is_channel_support_arm64="$(is_arm64_supported "$2")" + local architecture="$3"; + local osname="$(get_current_os_name)" + + if [ "$osname" == "osx" ] && [ "$architecture" == "arm64" ] && { [ "$is_version_support_arm64" = false ] || [ "$is_channel_support_arm64" = false ]; }; then + #check if rosetta is installed + if [ "$(/usr/bin/pgrep oahd >/dev/null 2>&1;echo $?)" -eq 0 ]; then + say_verbose "Changing user architecture from '$architecture' to 'x64' because .NET SDKs prior to version 6.0 do not support arm64." + echo "x64" + return 0; + else + say_err "Architecture \`$architecture\` is not supported for .NET SDK version \`$version\`. Please install Rosetta to allow emulation of the \`$architecture\` .NET SDK on this platform" + return 1 + fi + fi + + echo "$architecture" + return 0 +} + +# args: +# version or channel - $1 +is_arm64_supported() { + #any channel or version that starts with the specified versions + case "$1" in + ( "1"* | "2"* | "3"* | "4"* | "5"*) + echo false + return 0 + esac + + echo true + return 0 +} + # args: # user_defined_os - $1 get_normalized_os() { @@ -523,7 +565,7 @@ parse_globaljson_file_for_version() { return 1 fi - sdk_section=$(cat $json_file | awk '/"sdk"/,/}/') + sdk_section=$(cat $json_file | tr -d "\r" | awk '/"sdk"/,/}/') if [ -z "$sdk_section" ]; then say_err "Unable to parse the SDK node in \`$json_file\`" return 1 @@ -988,8 +1030,6 @@ download() { sleep $((attempts*10)) done - - if [ "$failed" = true ]; then say_verbose "Download failed: $remote_path" return 1 @@ -1346,6 +1386,8 @@ calculate_vars() { install_root="$(resolve_installation_path "$install_dir")" say_verbose "InstallRoot: '$install_root'." + normalized_architecture="$(get_normalized_architecture_for_specific_sdk_version "$version" "$normalized_channel" "$normalized_architecture")" + if [[ "$runtime" == "dotnet" ]]; then asset_relative_path="shared/Microsoft.NETCore.App" asset_name=".NET Core Runtime"