diff --git a/images/macos/provision/core/vsmac.sh b/images/macos/provision/core/vsmac.sh index 2ab38f6e6..dfcb37ba9 100644 --- a/images/macos/provision/core/vsmac.sh +++ b/images/macos/provision/core/vsmac.sh @@ -4,14 +4,18 @@ source ~/utils/xamarin-utils.sh install_vsmac() { local VSMAC_VERSION=$1 - if [ $VSMAC_VERSION == "latest" ]; then + local VSMAC_DEFAULT=$2 + if [ $VSMAC_VERSION == "2019" ]; then VSMAC_DOWNLOAD_URL=$(curl -sL "https://aka.ms/manifest/stable" | jq -r '.items[] | select(.genericName=="VisualStudioMac").url') + elif [ $VSMAC_VERSION == "2022" ]; then + VSMAC_DOWNLOAD_URL=$(curl -sL "https://aka.ms/manifest/stable-2022" | 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 + echo "Installing Visual Studio ${VSMAC_VERSION} for Mac" TMPMOUNT=`/usr/bin/mktemp -d /tmp/visualstudio.XXXX` TMPMOUNT_DOWNLOADS="$TMPMOUNT/downloads" mkdir $TMPMOUNT_DOWNLOADS @@ -26,8 +30,8 @@ install_vsmac() { 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" + if [ $VSMAC_VERSION != $VSMAC_DEFAULT ]; then + mv "/Applications/Visual Studio.app" "/Applications/Visual Studio ${VSMAC_VERSION}.app" fi popd @@ -35,14 +39,11 @@ install_vsmac() { 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_VERSIONS=($(get_toolset_value '.xamarin.vsmac.versions[]')) +DEFAULT_VSMAC_VERSION=$(get_toolset_value '.xamarin.vsmac.default') -echo "Installing Visual Studio 2019 for Mac Stable" -VSMAC_VERSION_STABLE=$(get_toolset_value '.xamarin.vsmac') -install_vsmac $VSMAC_VERSION_STABLE +for VERSION in "${VSMAC_VERSIONS[@]}"; do + install_vsmac $VERSION $DEFAULT_VSMAC_VERSION +done invoke_tests "Common" "VSMac" diff --git a/images/macos/software-report/SoftwareReport.Generator.ps1 b/images/macos/software-report/SoftwareReport.Generator.ps1 index fb974d7ef..17d856609 100644 --- a/images/macos/software-report/SoftwareReport.Generator.ps1 +++ b/images/macos/software-report/SoftwareReport.Generator.ps1 @@ -247,12 +247,9 @@ $markdown += Build-WebServersSection # Xamarin section $markdown += New-MDHeader "Xamarin" -Level 3 -$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 "Visual Studio for Mac" -Level 4 +$markdown += Build-VSMacTable | New-MDTable +$markdown += New-MDNewLine $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 420103593..09cac3209 100644 --- a/images/macos/software-report/SoftwareReport.Xamarin.psm1 +++ b/images/macos/software-report/SoftwareReport.Xamarin.psm1 @@ -1,13 +1,26 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1" -function Get-VSMac2019Version { - $plistPath = "/Applications/Visual Studio.app/Contents/Info.plist" - return Run-Command "/usr/libexec/PlistBuddy -c 'Print CFBundleVersion' '$plistPath'" -} +function Build-VSMacTable { + $vsMacVersions = Get-ToolsetValue "xamarin.vsmac.versions" + $defaultVSMacVersion = Get-ToolsetValue "xamarin.vsmac.default" -function Get-VSMac2022Version { - $plistPath = "/Applications/Visual Studio Preview.app/Contents/Info.plist" - return Run-Command "/usr/libexec/PlistBuddy -c 'Print CFBundleVersion' '$plistPath'" + $vsMacVersions | ForEach-Object { + $isDefault = $_ -eq $defaultVSMacVersion + $vsPath = "/Applications/Visual Studio $_.app" + if ($isDefault) { + $vsPath = "/Applications/Visual Studio.app" + } + + $plistPath = "$vsPath/Contents/Info.plist" + $build = Run-Command "/usr/libexec/PlistBuddy -c 'Print CFBundleVersion' '$plistPath'" + $defaultPostfix = $isDefault ? " (default)" : "" + + [PSCustomObject] @{ + "Version" = $_ + $defaultPostfix + "Build" = $build + "Path" = $vsPath + } + } } function Get-NUnitVersion { @@ -33,4 +46,3 @@ function Build-XamarinTable { } } } - diff --git a/images/macos/tests/Common.Tests.ps1 b/images/macos/tests/Common.Tests.ps1 index 88f148e05..4a348e73c 100644 --- a/images/macos/tests/Common.Tests.ps1 +++ b/images/macos/tests/Common.Tests.ps1 @@ -79,15 +79,26 @@ Describe "CocoaPods" { } Describe "VSMac" { - It "VS4Mac is installed" { - $vsPath = "/Applications/Visual Studio.app" + $vsMacVersions = Get-ToolsetValue "xamarin.vsmac.versions" + $defaultVSMacVersion = Get-ToolsetValue "xamarin.vsmac.default" + + $testCases = $vsMacVersions | ForEach-Object { + $vsPath = "/Applications/Visual Studio $_.app" + if ($_ -eq $defaultVSMacVersion) { + $vsPath = "/Applications/Visual Studio.app" + } + + @{ vsversion = $_ ; vspath = $vsPath } + } + + It "Visual Studio for Mac is installed" -TestCases $testCases { $vstoolPath = Join-Path $vsPath "Contents/MacOS/vstool" $vsPath | Should -Exist $vstoolPath | Should -Exist } - It "VS4Mac Preview is installed" -Skip:(-not $os.IsMonterey) { - $vsPath = "/Applications/Visual Studio Preview.app" + It "Visual Studio $defaultVSMacVersion for Mac is default" { + $vsPath = "/Applications/Visual Studio.app" $vstoolPath = Join-Path $vsPath "Contents/MacOS/vstool" $vsPath | Should -Exist $vstoolPath | Should -Exist diff --git a/images/macos/toolsets/toolset-10.15.json b/images/macos/toolsets/toolset-10.15.json index 9361449de..096a85ebb 100644 --- a/images/macos/toolsets/toolset-10.15.json +++ b/images/macos/toolsets/toolset-10.15.json @@ -18,7 +18,10 @@ ] }, "xamarin": { - "vsmac": "latest", + "vsmac": { + "default": "2019", + "versions": [ "2019" ] + }, "mono-versions": [ "6.12.0.162", "6.10.0.106", "6.8.0.123", "6.6.0.166", "6.4.0.208" ], diff --git a/images/macos/toolsets/toolset-11.json b/images/macos/toolsets/toolset-11.json index 985201ec7..4be38c198 100644 --- a/images/macos/toolsets/toolset-11.json +++ b/images/macos/toolsets/toolset-11.json @@ -12,7 +12,10 @@ ] }, "xamarin": { - "vsmac": "latest", + "vsmac": { + "default": "2022", + "versions": [ "2019", "2022" ] + }, "mono-versions": [ "6.12.0.174" ], diff --git a/images/macos/toolsets/toolset-12.json b/images/macos/toolsets/toolset-12.json index 1cb3633a1..c367898f9 100644 --- a/images/macos/toolsets/toolset-12.json +++ b/images/macos/toolsets/toolset-12.json @@ -9,8 +9,10 @@ ] }, "xamarin": { - "vsmac": "latest", - "vsmac_preview": "preview", + "vsmac": { + "default": "2022", + "versions": [ "2019", "2022" ] + }, "mono-versions": [ "6.12.0.174" ],