From 82d69fd301389dfde695f3c45eef102bff6e7eee Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov <47745270+al-cheb@users.noreply.github.com> Date: Wed, 18 May 2022 16:49:37 +0200 Subject: [PATCH] [macOS] Add VSForMac 2022 Preview (#5561) --- images/macos/provision/core/vsmac.sh | 61 ++++++++++++------- .../SoftwareReport.Generator.ps1 | 8 ++- .../SoftwareReport.Xamarin.psm1 | 7 ++- images/macos/tests/Common.Tests.ps1 | 7 +++ images/macos/toolsets/toolset-12.json | 1 + 5 files changed, 60 insertions(+), 24 deletions(-) diff --git a/images/macos/provision/core/vsmac.sh b/images/macos/provision/core/vsmac.sh index f4f91456..2ab38f6e 100644 --- a/images/macos/provision/core/vsmac.sh +++ b/images/macos/provision/core/vsmac.sh @@ -2,28 +2,47 @@ source ~/utils/utils.sh source ~/utils/xamarin-utils.sh -VSMAC_VERSION=$(get_toolset_value '.xamarin.vsmac') -if [ $VSMAC_VERSION == "latest" ]; then - VSMAC_VERSION=$(curl -L "http://aka.ms/manifest/stable" | jq -r ".items[] | select(.genericName==\"VisualStudioMac\").version") +install_vsmac() { + local VSMAC_VERSION=$1 + if [ $VSMAC_VERSION == "latest" ]; then + VSMAC_DOWNLOAD_URL=$(curl -sL "https://aka.ms/manifest/stable" | jq -r '.items[] | select(.genericName=="VisualStudioMac").url') + elif [ $VSMAC_VERSION == "preview" ]; then + VSMAC_DOWNLOAD_URL=$(curl -sL "https://aka.ms/manifest/preview" | jq -r '.items[] | select(.genericName=="VisualStudioMac").url') + else + VSMAC_DOWNLOAD_URL=$(buildVSMacDownloadUrl $VSMAC_VERSION) + fi + + TMPMOUNT=`/usr/bin/mktemp -d /tmp/visualstudio.XXXX` + TMPMOUNT_DOWNLOADS="$TMPMOUNT/downloads" + mkdir $TMPMOUNT_DOWNLOADS + + download_with_retries $VSMAC_DOWNLOAD_URL $TMPMOUNT_DOWNLOADS + + echo "Mounting Visual Studio..." + VISUAL_STUDIO_NAME=${VSMAC_DOWNLOAD_URL##*/} + hdiutil attach "$TMPMOUNT_DOWNLOADS/$VISUAL_STUDIO_NAME" -mountpoint "$TMPMOUNT" + + echo "Moving Visual Studio to /Applications/..." + pushd $TMPMOUNT + tar cf - "./Visual Studio.app" | tar xf - -C /Applications/ + + if [ $VSMAC_VERSION == "preview" ]; then + mv "/Applications/Visual Studio.app" "/Applications/Visual Studio Preview.app" + fi + + popd + sudo hdiutil detach "$TMPMOUNT" + sudo rm -rf "$TMPMOUNT" +} + +VSMAC_VERSION_PREVIEW=$(get_toolset_value '.xamarin.vsmac_preview') +if [ $VSMAC_VERSION_PREVIEW != "null" ];then + echo "Installing Visual Studio 2022 for Mac Preview" + install_vsmac $VSMAC_VERSION_PREVIEW fi -VSMAC_DOWNLOAD_URL=$(buildVSMacDownloadUrl $VSMAC_VERSION) -TMPMOUNT=`/usr/bin/mktemp -d /tmp/visualstudio.XXXX` -TMPMOUNT_DOWNLOADS="$TMPMOUNT/downloads" -mkdir $TMPMOUNT_DOWNLOADS - -download_with_retries $VSMAC_DOWNLOAD_URL $TMPMOUNT_DOWNLOADS - -echo "Mounting Visual studio..." -VISUAL_STUDIO_NAME=${VSMAC_DOWNLOAD_URL##*/} -hdiutil attach "$TMPMOUNT_DOWNLOADS/$VISUAL_STUDIO_NAME" -mountpoint "$TMPMOUNT" - -echo "Moving Visual Studio to /Applications/..." -pushd $TMPMOUNT -tar cf - "./Visual Studio.app" | tar xf - -C /Applications/ - -popd -sudo hdiutil detach "$TMPMOUNT" -sudo rm -rf "$TMPMOUNT" +echo "Installing Visual Studio 2019 for Mac Stable" +VSMAC_VERSION_STABLE=$(get_toolset_value '.xamarin.vsmac') +install_vsmac $VSMAC_VERSION_STABLE invoke_tests "Common" "VSMac" diff --git a/images/macos/software-report/SoftwareReport.Generator.ps1 b/images/macos/software-report/SoftwareReport.Generator.ps1 index cb740aae..a97a2990 100644 --- a/images/macos/software-report/SoftwareReport.Generator.ps1 +++ b/images/macos/software-report/SoftwareReport.Generator.ps1 @@ -242,8 +242,12 @@ $markdown += Build-WebServersSection # Xamarin section $markdown += New-MDHeader "Xamarin" -Level 3 -$markdown += New-MDHeader "Visual Studio for Mac" -Level 4 -$markdown += New-MDList -Lines @(Get-VSMacVersion) -Style Unordered +$markdown += New-MDHeader "Visual Studio 2019 for Mac" -Level 4 +$markdown += New-MDList -Lines @(Get-VSMac2019Version) -Style Unordered +if ($os.IsMonterey) { + $markdown += New-MDHeader "Visual Studio 2022 for Mac" -Level 4 + $markdown += New-MDList -Lines @(Get-VSMac2022Version) -Style Unordered +} $markdown += New-MDHeader "Xamarin bundles" -Level 4 $markdown += Build-XamarinTable | New-MDTable diff --git a/images/macos/software-report/SoftwareReport.Xamarin.psm1 b/images/macos/software-report/SoftwareReport.Xamarin.psm1 index 2bd1b547..42010359 100644 --- a/images/macos/software-report/SoftwareReport.Xamarin.psm1 +++ b/images/macos/software-report/SoftwareReport.Xamarin.psm1 @@ -1,10 +1,15 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1" -function Get-VSMacVersion { +function Get-VSMac2019Version { $plistPath = "/Applications/Visual Studio.app/Contents/Info.plist" return Run-Command "/usr/libexec/PlistBuddy -c 'Print CFBundleVersion' '$plistPath'" } +function Get-VSMac2022Version { + $plistPath = "/Applications/Visual Studio Preview.app/Contents/Info.plist" + return Run-Command "/usr/libexec/PlistBuddy -c 'Print CFBundleVersion' '$plistPath'" +} + function Get-NUnitVersion { $version = Run-Command "nunit3-console --version" | Select-Object -First 1 | Take-Part -Part 3 return "NUnit ${version}" diff --git a/images/macos/tests/Common.Tests.ps1 b/images/macos/tests/Common.Tests.ps1 index 3c9a717e..7938abfa 100644 --- a/images/macos/tests/Common.Tests.ps1 +++ b/images/macos/tests/Common.Tests.ps1 @@ -85,6 +85,13 @@ Describe "VSMac" { $vsPath | Should -Exist $vstoolPath | Should -Exist } + + It "VS4Mac Preview is installed" -Skip:(-not $os.IsMonterey) { + $vsPath = "/Applications/Visual Studio Preview.app" + $vstoolPath = Join-Path $vsPath "Contents/MacOS/vstool" + $vsPath | Should -Exist + $vstoolPath | Should -Exist + } } Describe "Swig" { diff --git a/images/macos/toolsets/toolset-12.json b/images/macos/toolsets/toolset-12.json index a9ffcbcd..b093504d 100644 --- a/images/macos/toolsets/toolset-12.json +++ b/images/macos/toolsets/toolset-12.json @@ -10,6 +10,7 @@ }, "xamarin": { "vsmac": "latest", + "vsmac_preview": "preview", "mono-versions": [ "6.12.0.174" ],