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

[macOS] Set Visual Studio 2022 for Mac by default #5614

Merged
merged 2 commits into from
May 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions images/macos/provision/core/vsmac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we still need this as it looks like all the downloads are now hosted in https://download.visualstudio.microsoft.com, not in dl.xamarin.com

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fi

echo "Installing Visual Studio ${VSMAC_VERSION} for Mac"
TMPMOUNT=`/usr/bin/mktemp -d /tmp/visualstudio.XXXX`
TMPMOUNT_DOWNLOADS="$TMPMOUNT/downloads"
mkdir $TMPMOUNT_DOWNLOADS
Expand All @@ -26,23 +30,20 @@ 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
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_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"
9 changes: 3 additions & 6 deletions images/macos/software-report/SoftwareReport.Generator.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 20 additions & 8 deletions images/macos/software-report/SoftwareReport.Xamarin.psm1
Original file line number Diff line number Diff line change
@@ -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"

$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)" : ""

function Get-VSMac2022Version {
$plistPath = "/Applications/Visual Studio Preview.app/Contents/Info.plist"
return Run-Command "/usr/libexec/PlistBuddy -c 'Print CFBundleVersion' '$plistPath'"
[PSCustomObject] @{
"Version" = $_ + $defaultPostfix
"Build" = $build
"Path" = $vsPath
}
}
}

function Get-NUnitVersion {
Expand All @@ -33,4 +46,3 @@ function Build-XamarinTable {
}
}
}

19 changes: 15 additions & 4 deletions images/macos/tests/Common.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 <vsversion> 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
Expand Down
5 changes: 4 additions & 1 deletion images/macos/toolsets/toolset-10.15.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
],
Expand Down
5 changes: 4 additions & 1 deletion images/macos/toolsets/toolset-11.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
]
},
"xamarin": {
"vsmac": "latest",
"vsmac": {
"default": "2022",
"versions": [ "2019", "2022" ]
},
"mono-versions": [
"6.12.0.174"
],
Expand Down
6 changes: 4 additions & 2 deletions images/macos/toolsets/toolset-12.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
]
},
"xamarin": {
"vsmac": "latest",
"vsmac_preview": "preview",
"vsmac": {
"default": "2022",
"versions": [ "2019", "2022" ]
},
"mono-versions": [
"6.12.0.174"
],
Expand Down