From cfacab19e6cf234eb85792e95d967302ae27df93 Mon Sep 17 00:00:00 2001 From: Dibir Magomedsaygitov <61747324+dibir-magomedsaygitov@users.noreply.github.com> Date: Wed, 22 Dec 2021 10:38:22 +0300 Subject: [PATCH] [macOS] Rework PowerShell installation (#4778) --- images/macos/provision/core/powershell.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/images/macos/provision/core/powershell.sh b/images/macos/provision/core/powershell.sh index 834744856..289b6106c 100644 --- a/images/macos/provision/core/powershell.sh +++ b/images/macos/provision/core/powershell.sh @@ -2,7 +2,16 @@ source ~/utils/utils.sh echo Installing PowerShell... -brew install --cask powershell +psRelease=$(curl -s "https://api.github.com/repos/PowerShell/PowerShell/releases/latest") +psDownloadUrl=$(echo $psRelease | jq -r '.assets[].browser_download_url | select(contains("osx-x64.pkg"))' | head -n 1) +download_with_retries $psDownloadUrl "/tmp" "powershell.pkg" + +# Work around the issue on macOS Big Sur 11.5 or higher for possible error message ("can't be opened because Apple cannot check it for malicious software") when installing the package +if ! is_Less_BigSur; then + sudo xattr -rd com.apple.quarantine /tmp/powershell.pkg +fi + +sudo installer -pkg /tmp/powershell.pkg -target / # Install PowerShell modules psModules=$(get_toolset_value '.powershellModules[].name')