Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Windows-arm #320

Merged
merged 6 commits into from Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/index.js
Expand Up @@ -275,7 +275,7 @@ 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);
const powershellPath = (yield io.which('pwsh', false)) || (yield io.which('powershell', true));
var options = {
listeners: {
stdout: (data) => {
Expand Down
48 changes: 45 additions & 3 deletions externals/install-dotnet.sh
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -988,8 +1030,6 @@ download() {
sleep $((attempts*10))
done



if [ "$failed" = true ]; then
say_verbose "Download failed: $remote_path"
return 1
Expand Down Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion src/installer.ts
Expand Up @@ -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('powershell', true);
const powershellPath =
(await io.which('pwsh', false)) || (await io.which('powershell', true));

var options: ExecOptions = {
listeners: {
Expand Down