From 6bd8f44edcc4986547d0c986a96f38000b031cf7 Mon Sep 17 00:00:00 2001 From: Thomas Boop Date: Fri, 16 Sep 2022 10:11:37 -0400 Subject: [PATCH 1/6] update to use pwsh if it is available --- dist/index.js | 5 ++++- src/installer.ts | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index d897c56a4..7b8699db6 100644 --- a/dist/index.js +++ b/dist/index.js @@ -275,7 +275,10 @@ class DotnetCoreInstaller { command += ` -ProxyBypassList ${process.env['no_proxy']}`; } // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used - const powershellPath = yield io.which('powershell', true); + let powershellPath = yield io.which('pwsh', false); + if (powershellPath == '') { + powershellPath = yield io.which('powershell', true); + } var options = { listeners: { stdout: (data) => { diff --git a/src/installer.ts b/src/installer.ts index c25d23a0a..368c4c96e 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -116,7 +116,11 @@ export class DotnetCoreInstaller { } // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used - const powershellPath = await io.which('powershell', true); + let powershellPath = await io.which('pwsh', false); + if (powershellPath == '') + { + powershellPath = await io.which('powershell', true); + } var options: ExecOptions = { listeners: { From 7b7f8c2fb99d7387f9043e635432d2388d8c4378 Mon Sep 17 00:00:00 2001 From: Thomas Boop Date: Fri, 16 Sep 2022 10:13:09 -0400 Subject: [PATCH 2/6] fix spacing --- src/installer.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/installer.ts b/src/installer.ts index 368c4c96e..dc4a253a3 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -117,8 +117,7 @@ export class DotnetCoreInstaller { // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used let powershellPath = await io.which('pwsh', false); - if (powershellPath == '') - { + if (powershellPath == '') { powershellPath = await io.which('powershell', true); } From 9cf8ed967134c2a6cc793d4a242ae035a5f7fb8e Mon Sep 17 00:00:00 2001 From: Thomas Boop Date: Fri, 16 Sep 2022 11:20:03 -0400 Subject: [PATCH 3/6] update install script --- 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 55f43507c..3e16cc9da 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" From 94bf0052b37d428db9aac5c65c01887ba4da2b7a Mon Sep 17 00:00:00 2001 From: Thomas Boop <52323235+thboop@users.noreply.github.com> Date: Thu, 22 Sep 2022 09:45:47 -0400 Subject: [PATCH 4/6] Update src/installer.ts Co-authored-by: Ivan <98037481+IvanZosimov@users.noreply.github.com> --- src/installer.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/installer.ts b/src/installer.ts index dc4a253a3..1d1013eaa 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -116,10 +116,7 @@ export class DotnetCoreInstaller { } // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used - let powershellPath = await io.which('pwsh', false); - if (powershellPath == '') { - powershellPath = await io.which('powershell', true); - } + const powershellPath = await io.which('pwsh', false) || await io.which('powershell', true); var options: ExecOptions = { listeners: { From 5b90157acce646a27c914620b016eb29d7c5bdce Mon Sep 17 00:00:00 2001 From: Thomas Boop Date: Thu, 22 Sep 2022 09:46:28 -0400 Subject: [PATCH 5/6] update index.js --- dist/index.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index 7b8699db6..553f9911e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -275,10 +275,7 @@ class DotnetCoreInstaller { command += ` -ProxyBypassList ${process.env['no_proxy']}`; } // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used - let powershellPath = yield io.which('pwsh', false); - if (powershellPath == '') { - powershellPath = yield io.which('powershell', true); - } + const powershellPath = (yield io.which('pwsh', false)) || (yield io.which('powershell', true)); var options = { listeners: { stdout: (data) => { From 0802949ecca11d0537a9573886a43028fbf878e2 Mon Sep 17 00:00:00 2001 From: Thomas Boop Date: Thu, 22 Sep 2022 09:52:36 -0400 Subject: [PATCH 6/6] fix format --- src/installer.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/installer.ts b/src/installer.ts index 1d1013eaa..d5911d9f2 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -116,7 +116,8 @@ export class DotnetCoreInstaller { } // process.env must be explicitly passed in for DOTNET_INSTALL_DIR to be used - const powershellPath = await io.which('pwsh', false) || await io.which('powershell', true); + const powershellPath = + (await io.which('pwsh', false)) || (await io.which('powershell', true)); var options: ExecOptions = { listeners: {