From da68de0a0932dbaf6f7cac642d38a68af2e66618 Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Thu, 1 Oct 2020 13:11:30 +0300 Subject: [PATCH 1/2] Implement logic to check if xcode is beta --- images/macos/helpers/Xcode.Helpers.psm1 | 10 +++++++++- images/macos/software-report/SoftwareReport.Xcode.psm1 | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/images/macos/helpers/Xcode.Helpers.psm1 b/images/macos/helpers/Xcode.Helpers.psm1 index dbc4803c..c4a5ca70 100644 --- a/images/macos/helpers/Xcode.Helpers.psm1 +++ b/images/macos/helpers/Xcode.Helpers.psm1 @@ -45,6 +45,14 @@ function Switch-Xcode { Invoke-Expression "sudo xcode-select --switch ${XcodeRootPath}" } +function Test-XcodeStableRelease { + param([string] $XcodeRootPath) + + $licenseInfoPlistPath = Join-Path $XcodeRootPath "Contents" "Resources" "LicenseInfo.plist" + $releaseType = & defaults read $licenseInfoPlistPath "licenseType" + return -not ($releaseType -match "beta") +} + function Get-XcodeSimulatorsInfo { param( [string] $Filter @@ -102,6 +110,6 @@ function Test-XcodeStableVersion { if ($Version -match "GM") { return $false } - + return $true } \ No newline at end of file diff --git a/images/macos/software-report/SoftwareReport.Xcode.psm1 b/images/macos/software-report/SoftwareReport.Xcode.psm1 index 59754d58..3d4cfa52 100644 --- a/images/macos/software-report/SoftwareReport.Xcode.psm1 +++ b/images/macos/software-report/SoftwareReport.Xcode.psm1 @@ -46,7 +46,8 @@ function Get-XcodeInfoList { $versionInfo = Get-XcodeVersionInfo $versionInfo.Path = $xcodeRootPath $versionInfo.IsDefault = ($xcodeRootPath -eq $defaultXcodeRootPath) - + $versionInfo.IsStable = Test-XcodeStableRelease -XcodeRootPath $xcodeRootPath + $xcodeInfo.Add($xcodeRootPath, [PSCustomObject] @{ VersionInfo = $versionInfo SDKInfo = Get-XcodeSDKList @@ -91,6 +92,7 @@ function Build-XcodeTable { $xcodeList = $xcodeInfo.Values | ForEach-Object { $_.VersionInfo } | Sort-Object $sortRules return $xcodeList | ForEach-Object { $defaultPostfix = If ($_.IsDefault) { " (default)" } else { "" } + $betaPostfix = If ($_.IsStable) { "" } else { " (beta)" } return [PSCustomObject] @{ "Version" = $_.Version.ToString() + $betaPostfix + $defaultPostfix "Build" = $_.Build From fc8383a81ea4c0b8a65e530c5195af7f111ff8e2 Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Fri, 2 Oct 2020 08:05:11 +0300 Subject: [PATCH 2/2] Update Xcode.Helpers.psm1 --- images/macos/helpers/Xcode.Helpers.psm1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/images/macos/helpers/Xcode.Helpers.psm1 b/images/macos/helpers/Xcode.Helpers.psm1 index c4a5ca70..8ea137e6 100644 --- a/images/macos/helpers/Xcode.Helpers.psm1 +++ b/images/macos/helpers/Xcode.Helpers.psm1 @@ -46,7 +46,10 @@ function Switch-Xcode { } function Test-XcodeStableRelease { - param([string] $XcodeRootPath) + param( + [Parameter(Mandatory)] + [string] $XcodeRootPath + ) $licenseInfoPlistPath = Join-Path $XcodeRootPath "Contents" "Resources" "LicenseInfo.plist" $releaseType = & defaults read $licenseInfoPlistPath "licenseType"