diff --git a/images/macos/scripts/build/Configure-Toolset.ps1 b/images/macos/scripts/build/Configure-Toolset.ps1 index 8450b820d..4580d0247 100644 --- a/images/macos/scripts/build/Configure-Toolset.ps1 +++ b/images/macos/scripts/build/Configure-Toolset.ps1 @@ -6,8 +6,7 @@ Import-Module "~/image-generation/helpers/Common.Helpers.psm1" -function Get-ToolsetToolFullPath -{ +function Get-ToolsetToolFullPath { param ( [Parameter(Mandatory)] [string] $ToolName, @@ -23,25 +22,23 @@ function Get-ToolsetToolFullPath } $arch = Get-Architecture -$toolcache = Get-ToolsetValue "toolcache" +$toolcache = (Get-ToolsetContent).toolcache -foreach ($tool in $toolcache) -{ +foreach ($tool in $toolcache) { $toolName = $tool.name $toolEnvironment = $tool.arch.$arch.variable_template - if (-not $toolEnvironment) - { + if (-not $toolEnvironment) { continue } - foreach ($toolVersion in $tool.arch.$arch.versions) - { + foreach ($toolVersion in $tool.arch.$arch.versions) { Write-Host "Set $toolName $toolVersion environment variable..." $toolPath = Get-ToolsetToolFullPath -ToolName $toolName -ToolVersion $toolVersion -ToolArchitecture $arch $envName = $toolEnvironment -f $toolVersion.split(".") # Add environment variable name=value - Add-EnvironmentVariable -Name $envName -Value $toolPath + $envVar = "export {0}={1}" -f $envName, $toolPath + Add-Content -Path "${env:HOME}/.bashrc" -Value $envVar } } diff --git a/images/macos/scripts/build/Install-Toolset.ps1 b/images/macos/scripts/build/Install-Toolset.ps1 index d5a278574..1e81cd27b 100644 --- a/images/macos/scripts/build/Install-Toolset.ps1 +++ b/images/macos/scripts/build/Install-Toolset.ps1 @@ -31,11 +31,11 @@ $arch = Get-Architecture # Get toolcache content from toolset $toolsToInstall = @("Python", "Node", "Go") -$tools = Get-ToolsetValue "toolcache" | Where-Object {$toolsToInstall -contains $_.Name} +$tools = (Get-ToolsetContent).toolcache | Where-Object {$toolsToInstall -contains $_.Name} foreach ($tool in $tools) { # Get versions manifest for current tool - $assets = Invoke-RestMethodWithRetry -Url $tool.url + $assets = Invoke-RestMethod $tool.url -MaximumRetryCount 10 -RetryIntervalSec 30 # Get github release asset for each version foreach ($version in $tool.arch.$arch.versions) { diff --git a/images/macos/scripts/build/Install-Xcode.ps1 b/images/macos/scripts/build/Install-Xcode.ps1 index eec15f51a..1e4edfc1f 100644 --- a/images/macos/scripts/build/Install-Xcode.ps1 +++ b/images/macos/scripts/build/Install-Xcode.ps1 @@ -8,10 +8,10 @@ $ErrorActionPreference = "Stop" Import-Module "$env:HOME/image-generation/helpers/Common.Helpers.psm1" Import-Module "$env:HOME/image-generation/helpers/Xcode.Installer.psm1" -DisableNameChecking -$ARCH = Get-Architecture -[Array]$xcodeVersions = Get-ToolsetValue "xcode.$ARCH.versions" +$arch = Get-Architecture +[Array]$xcodeVersions = (Get-ToolsetContent).xcode.$arch.versions write-host $xcodeVersions -$defaultXcode = Get-ToolsetValue "xcode.default" +$defaultXcode = (Get-ToolsetContent).xcode.default [Array]::Reverse($xcodeVersions) $threadCount = "5" @@ -61,7 +61,7 @@ $xcodeVersions | ForEach-Object { Write-Host "Rebuilding Launch Services database ..." $xcodeVersions | ForEach-Object { - Rebuild-XcodeLaunchServicesDb -Version $_.link + Initialize-XcodeLaunchServicesDb -Version $_.link } Write-Host "Setting default Xcode to $defaultXcode" diff --git a/images/macos/scripts/build/Update-XcodeSimulators.ps1 b/images/macos/scripts/build/Update-XcodeSimulators.ps1 index 7c083d8e4..7cc42fb55 100644 --- a/images/macos/scripts/build/Update-XcodeSimulators.ps1 +++ b/images/macos/scripts/build/Update-XcodeSimulators.ps1 @@ -8,16 +8,16 @@ $ErrorActionPreference = "Stop" Import-Module "$env:HOME/image-generation/helpers/Xcode.Helpers.psm1" -DisableNameChecking Import-Module "$env:HOME/image-generation/software-report/SoftwareReport.Xcode.psm1" -DisableNameChecking -function Ensure-SimulatorInstalled { +function Test-SimulatorInstalled { param( [Parameter(Mandatory)] - [string]$RuntimeId, + [string] $RuntimeId, [Parameter(Mandatory)] - [string]$DeviceId, + [string] $DeviceId, [Parameter(Mandatory)] - [string]$SimulatorName, + [string] $SimulatorName, [Parameter(Mandatory)] - [string]$XcodeVersion + [string] $XcodeVersion ) $simctlPath = Get-XcodeToolPath -Version $XcodeVersion -ToolName "simctl" @@ -52,5 +52,5 @@ Get-XcodeInfoList | Out-Null Write-Host "Validating and fixing Xcode simulators..." Get-BrokenXcodeSimulatorsList | ForEach-Object { - Ensure-SimulatorInstalled -RuntimeId $_.RuntimeId -DeviceId $_.DeviceId -SimulatorName $_.SimulatorName -XcodeVersion $_.XcodeVersion + Test-SimulatorInstalled -RuntimeId $_.RuntimeId -DeviceId $_.DeviceId -SimulatorName $_.SimulatorName -XcodeVersion $_.XcodeVersion } diff --git a/images/macos/scripts/build/install-android-sdk.sh b/images/macos/scripts/build/install-android-sdk.sh index 179338748..86eee8a7e 100644 --- a/images/macos/scripts/build/install-android-sdk.sh +++ b/images/macos/scripts/build/install-android-sdk.sh @@ -33,9 +33,9 @@ components=() ANDROID_PLATFORM=$(get_toolset_value '.android.platform_min_version') ANDROID_BUILD_TOOL=$(get_toolset_value '.android.build_tools_min_version') -ANDROID_EXTRA_LIST=($(get_toolset_value '.android."extra-list"[]')) -ANDROID_ADDON_LIST=($(get_toolset_value '.android."addon-list"[]')) -ANDROID_ADDITIONAL_TOOLS=($(get_toolset_value '.android."additional-tools"[]')) +ANDROID_EXTRA_LIST=($(get_toolset_value '.android."extras"[]')) +ANDROID_ADDON_LIST=($(get_toolset_value '.android."addons"[]')) +ANDROID_ADDITIONAL_TOOLS=($(get_toolset_value '.android."additional_tools"[]')) ANDROID_NDK_MAJOR_VERSIONS=($(get_toolset_value '.android.ndk."versions"[]')) ANDROID_NDK_MAJOR_DEFAULT=$(get_toolset_value '.android.ndk.default') ANDROID_NDK_MAJOR_LATEST=$(get_toolset_value '.android.ndk."versions"[-1]') diff --git a/images/macos/scripts/build/install-xamarin.sh b/images/macos/scripts/build/install-xamarin.sh index 3f9e7fcc3..8b956dade 100644 --- a/images/macos/scripts/build/install-xamarin.sh +++ b/images/macos/scripts/build/install-xamarin.sh @@ -7,12 +7,12 @@ source ~/utils/utils.sh source ~/utils/xamarin-utils.sh -MONO_VERSIONS=($(get_toolset_value '.xamarin."mono-versions" | reverse | .[]')) -XAMARIN_IOS_VERSIONS=($(get_toolset_value '.xamarin."ios-versions" | reverse | .[]')) -XAMARIN_MAC_VERSIONS=($(get_toolset_value '.xamarin."mac-versions" | reverse | .[]')) -XAMARIN_ANDROID_VERSIONS=($(get_toolset_value '.xamarin."android-versions" | reverse | .[]')) +MONO_VERSIONS=($(get_toolset_value '.xamarin."mono_versions" | reverse | .[]')) +XAMARIN_IOS_VERSIONS=($(get_toolset_value '.xamarin."ios_versions" | reverse | .[]')) +XAMARIN_MAC_VERSIONS=($(get_toolset_value '.xamarin."mac_versions" | reverse | .[]')) +XAMARIN_ANDROID_VERSIONS=($(get_toolset_value '.xamarin."android_versions" | reverse | .[]')) LATEST_SDK_SYMLINK=$(get_toolset_value '.xamarin.bundles[0].symlink') -CURRENT_SDK_SYMLINK=$(get_toolset_value '.xamarin."bundle-default"') +CURRENT_SDK_SYMLINK=$(get_toolset_value '.xamarin."bundle_default"') DEFAULT_XCODE_VERSION=$(get_toolset_value '.xcode.default') if [ "$CURRENT_SDK_SYMLINK" == "latest" ]; then diff --git a/images/macos/scripts/docs-gen/SoftwareReport.Android.psm1 b/images/macos/scripts/docs-gen/SoftwareReport.Android.psm1 index 22cf4a5c9..66e68813f 100644 --- a/images/macos/scripts/docs-gen/SoftwareReport.Android.psm1 +++ b/images/macos/scripts/docs-gen/SoftwareReport.Android.psm1 @@ -2,9 +2,10 @@ Import-Module "$PSScriptRoot/SoftwareReport.Helpers.psm1" -DisableNameChecking Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1" function Split-TableRowByColumns { - param( + param ( [string] $Row ) + return $Row.Split("|") | ForEach-Object { $_.trim() } } @@ -46,6 +47,7 @@ function Get-AndroidPackages { function Build-AndroidTable { Write-Host "Build-AndroidTable" $packageInfo = Get-AndroidInstalledPackages + return @( @{ "Package" = "Android Command Line Tools" @@ -62,7 +64,7 @@ function Build-AndroidTable { @{ "Package" = "Android SDK Platforms" "Version" = Get-AndroidPlatformVersions -PackageInfo $packageInfo - }, + }, @{ "Package" = "Android SDK Platform-Tools" "Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Android SDK Platform-Tools" @@ -111,6 +113,7 @@ function Build-AndroidEnvironmentTable { $androidVersions = Get-Item env:ANDROID_* $shoulddResolveLink = 'ANDROID_NDK', 'ANDROID_NDK_HOME', 'ANDROID_NDK_ROOT', 'ANDROID_NDK_LATEST_HOME' + return $androidVersions | Sort-Object -Property Name | ForEach-Object { [PSCustomObject] @{ "Name" = $_.Name @@ -191,7 +194,7 @@ function Get-AndroidGoogleAPIsVersions { function Get-AndroidNDKVersions { $ndkFolderPath = Join-Path (Get-AndroidSDKRoot) "ndk" $versions += Get-ChildItem -Path $ndkFolderPath -Name - $ndkDefaultVersion = Get-ToolsetValue "android.ndk.default" + $ndkDefaultVersion = (Get-ToolsetContent).android.ndk.default $ndkDefaultFullVersion = Get-ChildItem "$env:ANDROID_HOME/ndk/$ndkDefaultVersion.*" -Name | Select-Object -Last 1 return ($versions | ForEach-Object { diff --git a/images/macos/scripts/docs-gen/SoftwareReport.Browsers.psm1 b/images/macos/scripts/docs-gen/SoftwareReport.Browsers.psm1 index e19865bc0..f99a90be4 100644 --- a/images/macos/scripts/docs-gen/SoftwareReport.Browsers.psm1 +++ b/images/macos/scripts/docs-gen/SoftwareReport.Browsers.psm1 @@ -10,7 +10,7 @@ function Build-BrowserSection { [ToolVersionNode]::new("Google Chrome for Testing", $(Get-ChromeForTestingVersion)) [ToolVersionNode]::new("ChromeDriver", $(Get-ChromeDriverVersion)) ) - + if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) { $nodes += @( [ToolVersionNode]::new("Microsoft Edge", $(Get-EdgeVersion)) @@ -19,7 +19,7 @@ function Build-BrowserSection { [ToolVersionNode]::new("geckodriver", $(Get-GeckodriverVersion)) ) } - + $nodes += @( [ToolVersionNode]::new("Selenium server", $(Get-SeleniumVersion)) ) diff --git a/images/macos/scripts/docs-gen/SoftwareReport.Common.psm1 b/images/macos/scripts/docs-gen/SoftwareReport.Common.psm1 index 79e268399..b61a869b5 100644 --- a/images/macos/scripts/docs-gen/SoftwareReport.Common.psm1 +++ b/images/macos/scripts/docs-gen/SoftwareReport.Common.psm1 @@ -1,7 +1,5 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1" -$os = Get-OSVersion - function Get-BashVersion { $version = bash -c 'echo ${BASH_VERSION}' return $version @@ -83,7 +81,7 @@ function Get-VcpkgVersion { } function Get-GccVersions { - $versionList = Get-ToolsetValue -KeyPath gcc.versions + $versionList = (Get-ToolsetContent).gcc.versions $versionList | Foreach-Object { $nameVersion = Run-Command "gcc-${_} --version" | Select-Object -First 1 $version = ($nameVersion -replace "^gcc-${_}").Trim() -replace '\).*$', ')' @@ -92,7 +90,7 @@ function Get-GccVersions { } function Get-FortranVersions { - $versionList = Get-ToolsetValue -KeyPath gcc.versions + $versionList = (Get-ToolsetContent).gcc.versions $versionList | Foreach-Object { $nameVersion = Run-Command "gfortran-${_} --version" | Select-Object -First 1 $version = ($nameVersion -replace "^GNU Fortran").Trim() -replace '\).*$', ')' @@ -106,7 +104,7 @@ function Get-ClangLLVMVersions { $defaultClangOutput = Run-Command "clang --version" | Out-String $defaultClangVersion = $clangVersionRegex.Match($defaultClangOutput).Groups['version'].Value - $homebrewClangPath = '$(brew --prefix llvm@{0})/bin/clang' -f (Get-ToolsetValue 'llvm.version') + $homebrewClangPath = '$(brew --prefix llvm@{0})/bin/clang' -f ((Get-ToolsetContent).llvm.version) $homebrewClangOutput = Run-Command "$homebrewClangPath --version" | Out-String $homebrewClangVersion = $clangVersionRegex.Match($homebrewClangOutput).Groups['version'].Value diff --git a/images/macos/scripts/docs-gen/SoftwareReport.Helpers.psm1 b/images/macos/scripts/docs-gen/SoftwareReport.Helpers.psm1 index 3dfc84963..cd92f7bf0 100644 --- a/images/macos/scripts/docs-gen/SoftwareReport.Helpers.psm1 +++ b/images/macos/scripts/docs-gen/SoftwareReport.Helpers.psm1 @@ -47,7 +47,7 @@ function Get-BrewPackageVersion { [string] $CommandName ) - (Get-LinkTarget (Get-Command $CommandName).Source | Out-String) -match "(?(\d+.){2}\d+)" | Out-Null + (Get-LinkTarget (Get-Command $CommandName).Source | Out-String) -match "(?(\d+.){2}\d+)" | Out-Null $packageVersion = $Matches.Version return $packageVersion diff --git a/images/macos/scripts/docs-gen/SoftwareReport.Java.psm1 b/images/macos/scripts/docs-gen/SoftwareReport.Java.psm1 index 46c0a6def..41b591694 100644 --- a/images/macos/scripts/docs-gen/SoftwareReport.Java.psm1 +++ b/images/macos/scripts/docs-gen/SoftwareReport.Java.psm1 @@ -1,14 +1,15 @@ function Get-JavaVersions { $defaultJavaPath = (Get-Item env:JAVA_HOME).value - + $os = Get-OSVersion if ($os.IsVenturaArm64 -or $os.IsSonomaArm64) { $javaVersions = Get-Item env:JAVA_HOME_*_arm64 } else { $javaVersions = Get-Item env:JAVA_HOME_*_X64 } + $sortRules = @{ - Expression = { [Int32]$_.Name.Split("_")[2] } + Expression = { [Int32]$_.Name.Split("_")[2] } Descending = $false } diff --git a/images/macos/scripts/docs-gen/SoftwareReport.Toolcache.psm1 b/images/macos/scripts/docs-gen/SoftwareReport.Toolcache.psm1 index a7187eb55..ad5c41881 100644 --- a/images/macos/scripts/docs-gen/SoftwareReport.Toolcache.psm1 +++ b/images/macos/scripts/docs-gen/SoftwareReport.Toolcache.psm1 @@ -54,7 +54,7 @@ function Build-ToolcacheSection { } function Get-PowerShellModules { - $modules = (Get-ToolsetValue powershellModules).name + $modules = ((Get-ToolsetContent).powershellModules).name $modules | ForEach-Object { $moduleName = $_ $moduleVersions = Get-Module -Name $moduleName -ListAvailable | Select-Object -ExpandProperty Version | Sort-Object -Unique diff --git a/images/macos/scripts/docs-gen/SoftwareReport.Xamarin.psm1 b/images/macos/scripts/docs-gen/SoftwareReport.Xamarin.psm1 index 1937ae73a..5275c323a 100644 --- a/images/macos/scripts/docs-gen/SoftwareReport.Xamarin.psm1 +++ b/images/macos/scripts/docs-gen/SoftwareReport.Xamarin.psm1 @@ -1,8 +1,8 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1" function Build-VSMacTable { - $vsMacVersions = Get-ToolsetValue "xamarin.vsmac.versions" - $defaultVSMacVersion = Get-ToolsetValue "xamarin.vsmac.default" + $vsMacVersions = (Get-ToolsetContent).xamarin.vsmac.versions + $defaultVSMacVersion = (Get-ToolsetContent).xamarin.vsmac.default return $vsMacVersions | ForEach-Object { $isDefault = $_ -eq $defaultVSMacVersion @@ -29,8 +29,8 @@ function Get-NUnitVersion { } function Build-XamarinTable { - $xamarinBundles = Get-ToolsetValue "xamarin.bundles" - $defaultSymlink = Get-ToolsetValue "xamarin.bundle-default" + $xamarinBundles = (Get-ToolsetContent).xamarin.bundles + $defaultSymlink = (Get-ToolsetContent).xamarin.bundle_default if ($defaultSymlink -eq "latest") { $defaultSymlink = $xamarinBundles[0].symlink } @@ -38,7 +38,7 @@ function Build-XamarinTable { return $xamarinBundles | ForEach-Object { $defaultPostfix = ($_.symlink -eq $defaultSymlink ) ? " (default)" : "" [PSCustomObject] @{ - "symlink" = $_.symlink + $defaultPostfix + "symlink" = $_.symlink + $defaultPostfix "Xamarin.Mono" = $_.mono "Xamarin.iOS" = $_.ios "Xamarin.Mac" = $_.mac diff --git a/images/macos/scripts/docs-gen/SoftwareReport.Xcode.psm1 b/images/macos/scripts/docs-gen/SoftwareReport.Xcode.psm1 index b5d0de877..33edda8c1 100644 --- a/images/macos/scripts/docs-gen/SoftwareReport.Xcode.psm1 +++ b/images/macos/scripts/docs-gen/SoftwareReport.Xcode.psm1 @@ -4,7 +4,7 @@ Import-Module "$PSScriptRoot/../helpers/Xcode.Helpers.psm1" $os = Get-OSVersion function Get-XcodePaths { - $xcodePaths = Get-ChildItemWithoutSymlinks "/Applications" -Filter "Xcode_*.app" + $xcodePaths = Get-ChildItem -Path "/Applications" -Filter "Xcode_*.app" | Where-Object { !$_.LinkType } return $xcodePaths | Select-Object -ExpandProperty Fullname } diff --git a/images/macos/scripts/helpers/Common.Helpers.psm1 b/images/macos/scripts/helpers/Common.Helpers.psm1 index 627836f4a..0e8ea1e0c 100644 --- a/images/macos/scripts/helpers/Common.Helpers.psm1 +++ b/images/macos/scripts/helpers/Common.Helpers.psm1 @@ -7,6 +7,7 @@ function Get-CommandResult { # Bash trick to suppress and show error output because some commands write to stderr (for example, "python --version") $stdout = & bash -c "$Command 2>&1" $exitCode = $LASTEXITCODE + return @{ Output = If ($Multiline -eq $true) { $stdout } else { [string]$stdout } ExitCode = $exitCode @@ -14,21 +15,16 @@ function Get-CommandResult { } # Gets path to the tool, analogue of 'which tool' -function Get-WhichTool($tool) { +function Get-ToolPath($tool) { return (Get-Command $tool).Path } -# Gets value of environment variable by the name -function Get-EnvironmentVariable($variable) { - return [System.Environment]::GetEnvironmentVariable($variable) -} - # Returns the object with information about current OS # It can be used for OS-specific tests function Get-OSVersion { $osVersion = [Environment]::OSVersion - $osVersionMajorMinor = $osVersion.Version.ToString(2) $processorArchitecture = arch + return [PSCustomObject]@{ Version = $osVersion.Version Platform = $osVersion.Platform @@ -44,85 +40,11 @@ function Get-OSVersion { } } -function Get-ChildItemWithoutSymlinks { - param ( - [Parameter(Mandatory)] - [string] $Path, - [string] $Filter - ) - - $files = Get-ChildItem -Path $Path -Filter $Filter - $files = $files | Where-Object { !$_.LinkType } # cut symlinks - return $files -} - -# Get the value of specific toolset node -# Example, invoke `Get-ToolsetValue "xamarin.bundles"` to get value of `$toolsetJson.xamarin.bundles` -function Get-ToolsetValue { - param ( - [Parameter(Mandatory = $true)] - [string] $KeyPath - ) +# Get the value of the toolset +function Get-ToolsetContent { $toolsetPath = Join-Path $env:HOME "image-generation" "toolset.json" - $jsonNode = Get-Content -Raw $toolsetPath | ConvertFrom-Json - - $pathParts = $KeyPath.Split(".") - # try to walk through all arguments consequentially to resolve specific json node - $pathParts | ForEach-Object { - $jsonNode = $jsonNode.$_ - } - return $jsonNode -} - -function Get-ToolcachePackages { - $toolcachePath = Join-Path $env:HOME "image-generation" "toolcache.json" - return Get-Content -Raw $toolcachePath | ConvertFrom-Json -} - -function Invoke-RestMethodWithRetry { - param ( - [Parameter()] - [string] - $Url - ) - Invoke-RestMethod $Url -MaximumRetryCount 10 -RetryIntervalSec 30 -} - -function Invoke-ValidateCommand { - param( - [Parameter(Mandatory)] - [string]$Command, - [Uint] $Timeout = 0 - ) - - if ($Timeout -eq 0) - { - $output = Invoke-Expression -Command $Command - if ($LASTEXITCODE -ne 0) { - throw "Command '$Command' has finished with exit code $LASTEXITCODE" - } - return $output - } - else - { - $job = $command | Start-Job -ScriptBlock { - $output = Invoke-Expression -Command $input - if ($LASTEXITCODE -ne 0) { - throw 'Command failed' - } - return $output - } - $waitObject = $job | Wait-Job -Timeout $Timeout - if(-not $waitObject) - { - throw "Command '$Command' has timed out" - } - if($waitObject.State -eq 'Failed') - { - throw "Command '$Command' has failed" - } - Receive-Job -Job $job - } + $toolsetJson = Get-Content -Path $toolsetPath -Raw + ConvertFrom-Json -InputObject $toolsetJson } function Invoke-DownloadWithRetry { @@ -161,7 +83,7 @@ function Invoke-DownloadWithRetry { Write-Warning "Package download failed in $attemptSeconds seconds" Write-Warning $_.Exception.Message } - + if ($retries -eq 0) { $totalSeconds = [math]::Round(($(Get-Date) - $downloadStartTime).TotalSeconds, 2) throw "Package download failed after $totalSeconds seconds" @@ -174,37 +96,15 @@ function Invoke-DownloadWithRetry { return $Path } -function Add-EnvironmentVariable { - param - ( - [Parameter(Mandatory)] [string] $Name, - [Parameter(Mandatory)] [string] $Value, - [string] $FilePath = "${env:HOME}/.bashrc" - ) - - $envVar = "export {0}={1}" -f $Name, $Value - Add-Content -Path $FilePath -Value $envVar -} - function isVeertu { return (Test-Path -Path "/Library/Application Support/Veertu") } function Get-Architecture { $arch = arch - if ($arch -ne "arm64") - { + if ($arch -ne "arm64") { $arch = "x64" } return $arch } - -function Test-CommandExists { - param - ( - [Parameter(Mandatory)] [string] $Command - ) - - [boolean] (Get-Command $Command -ErrorAction 'SilentlyContinue') -} diff --git a/images/macos/scripts/helpers/Xcode.Helpers.psm1 b/images/macos/scripts/helpers/Xcode.Helpers.psm1 index e6411ce0c..a55d8de15 100644 --- a/images/macos/scripts/helpers/Xcode.Helpers.psm1 +++ b/images/macos/scripts/helpers/Xcode.Helpers.psm1 @@ -28,14 +28,15 @@ function Get-XcodeToolPath { } function Get-XcodeVersionInfo { - param( + param ( [Parameter(Mandatory)] - [string]$XcodeRootPath + [string] $XcodeRootPath ) $xcodebuildPath = Get-XcodeToolPath -XcodeRootPath $XcodeRootPath -ToolName "xcodebuild" [string]$output = Invoke-Expression "$xcodebuildPath -version" $versionOutputParts = $output.Split(" ") + return @{ Version = [System.Version]::Parse($versionOutputParts[1]) Build = $versionOutputParts[4] @@ -72,11 +73,12 @@ function Test-XcodeStableRelease { $licenseInfoPlistPath = Join-Path $XcodeRootPath "Contents" "Resources" "LicenseInfo.plist" $releaseType = & defaults read $licenseInfoPlistPath "licenseType" + return -not ($releaseType -match "beta") } function Get-XcodeSimulatorsInfo { - param( + param ( [string] $Filter ) @@ -106,6 +108,7 @@ function Get-XcodeDevicesList { $result += "$runtimeName $deviceName" } } + return $result } @@ -120,12 +123,13 @@ function Get-XcodePairsList { $phoneName = $_.Value.phone.name $result += "$watchName $phoneName" } + return $result } #Helper function for execution of xcversion due to: https://github.com/fastlane/fastlane/issues/18161 function Invoke-XCVersion { - param( + param ( [Parameter(Mandatory)] [string] $Arguments, [Parameter()] @@ -133,7 +137,7 @@ function Invoke-XCVersion { [Parameter()] [int] $PauseDurationSecs = 1 ) - + $Command = "xcversion $Arguments" Write-Host "Execute [$Command]" for ($Attempt=1; $Attempt -le $RetryAttempts; $Attempt++) { @@ -150,7 +154,7 @@ function Invoke-XCVersion { } if ($result.ExitCode -ne 0) { throw "Command [$Command] has finished with non-zero exit code." - } + } } function Get-BrokenXcodeSimulatorsList { @@ -305,4 +309,4 @@ function Get-BrokenXcodeSimulatorsList { XcodeVersion = "14.2" } ) -} \ No newline at end of file +} diff --git a/images/macos/scripts/helpers/Xcode.Installer.psm1 b/images/macos/scripts/helpers/Xcode.Installer.psm1 index 2413538c9..9ce10ac62 100644 --- a/images/macos/scripts/helpers/Xcode.Installer.psm1 +++ b/images/macos/scripts/helpers/Xcode.Installer.psm1 @@ -2,44 +2,41 @@ Import-Module "$PSScriptRoot/Common.Helpers.psm1" Import-Module "$PSScriptRoot/Xcode.Helpers.psm1" function Install-XcodeVersion { - param( + param ( [Parameter(Mandatory)] - [string]$Version, + [string] $Version, [Parameter(Mandatory)] - [string]$LinkTo + [string] $LinkTo ) $xcodeDownloadDirectory = "$env:HOME/Library/Caches/XcodeInstall" $xcodeTargetPath = Get-XcodeRootPath -Version $LinkTo $xcodeXipDirectory = Invoke-DownloadXcodeArchive -DownloadDirectory $xcodeDownloadDirectory -Version $Version Expand-XcodeXipArchive -DownloadDirectory $xcodeXipDirectory.FullName -TargetPath $xcodeTargetPath - Remove-Item -Path $xcodeXipDirectory -Force -Recurse } function Invoke-DownloadXcodeArchive { - param( + param ( [Parameter(Mandatory)] - [string]$DownloadDirectory, + [string] $DownloadDirectory, [Parameter(Mandatory)] - [string]$Version + [string] $Version ) Write-Host "Downloading Xcode $Version" - $tempXipDirectory = New-Item -Path $DownloadDirectory -Name "Xcode$Version" -ItemType "Directory" - $xcodeFileName = 'Xcode-{0}.xip' -f $Version $xcodeUri = '{0}{1}?{2}'-f ${env:XCODE_INSTALL_STORAGE_URL}, $xcodeFileName, ${env:XCODE_INSTALL_SAS} - Invoke-DownloadWithRetry -Url $xcodeUri -Path (Join-Path $tempXipDirectory.FullName $xcodeFileName) | Out-Null + return $tempXipDirectory } function Resolve-ExactXcodeVersion { - param( + param ( [Parameter(Mandatory)] - [string]$Version + [string] $Version ) # if toolset string contains spaces, consider it as a full name of Xcode @@ -50,6 +47,7 @@ function Resolve-ExactXcodeVersion { $semverVersion = [SemVer]::Parse($Version) $availableVersions = Get-AvailableXcodeVersions $satisfiedVersions = $availableVersions | Where-Object { $semverVersion -eq $_.stableSemver } + return $satisfiedVersions | Select-Object -Last 1 -ExpandProperty rawVersion } @@ -75,18 +73,18 @@ function Get-AvailableXcodeVersions { } function Expand-XcodeXipArchive { - param( + param ( [Parameter(Mandatory)] - [string]$DownloadDirectory, + [string] $DownloadDirectory, [Parameter(Mandatory)] - [string]$TargetPath + [string] $TargetPath ) $xcodeXipPath = Get-ChildItem -Path $DownloadDirectory -Filter "Xcode-*.xip" | Select-Object -First 1 Write-Host "Extracting Xcode from '$xcodeXipPath'" Push-Location $DownloadDirectory - if(Test-CommandExists 'unxip') { + if ([boolean] (Get-Command 'unxip' -ErrorAction 'SilentlyContinue')) { Invoke-ValidateCommand "unxip $xcodeXipPath" } else { Invoke-ValidateCommand "xip -x $xcodeXipPath" @@ -107,9 +105,9 @@ function Expand-XcodeXipArchive { } function Confirm-XcodeIntegrity { - param( + param ( [Parameter(Mandatory)] - [string]$Version + [string] $Version ) $XcodeRootPath = Get-XcodeRootPath -Version $Version @@ -120,13 +118,12 @@ function Confirm-XcodeIntegrity { } function Approve-XcodeLicense { - param( + param ( [Parameter(Mandatory)] - [string]$Version + [string] $Version ) $os = Get-OSVersion - $XcodeRootPath = Get-XcodeRootPath -Version $Version Write-Host "Approving Xcode license for '$XcodeRootPath'..." $xcodeBuildPath = Get-XcodeToolPath -XcodeRootPath $XcodeRootPath -ToolName "xcodebuild" @@ -139,9 +136,9 @@ function Approve-XcodeLicense { } function Install-XcodeAdditionalPackages { - param( + param ( [Parameter(Mandatory)] - [string]$Version + [string] $Version ) Write-Host "Installing additional packages for Xcode $Version..." @@ -153,9 +150,9 @@ function Install-XcodeAdditionalPackages { } function Invoke-XcodeRunFirstLaunch { - param( + param ( [Parameter(Mandatory)] - [string]$Version + [string] $Version ) if ($Version.StartsWith("8") -or $Version.StartsWith("9")) { @@ -168,9 +165,9 @@ function Invoke-XcodeRunFirstLaunch { } function Install-AdditionalSimulatorRuntimes { - param( + param ( [Parameter(Mandatory)] - [string]$Version + [string] $Version ) Write-Host "Installing Simulator Runtimes for Xcode $Version ..." @@ -179,10 +176,10 @@ function Install-AdditionalSimulatorRuntimes { } function Build-XcodeSymlinks { - param( + param ( [Parameter(Mandatory)] - [string]$Version, - [string[]]$Symlinks + [string] $Version, + [string[]] $Symlinks ) $sourcePath = Get-XcodeRootPath -Version $Version @@ -193,10 +190,10 @@ function Build-XcodeSymlinks { } } -function Rebuild-XcodeLaunchServicesDb { - param( +function Initialize-XcodeLaunchServicesDb { + param ( [Parameter(Mandatory)] - [string]$Version + [string] $Version ) $xcodePath = Get-XcodeRootPath -Version $Version @@ -205,9 +202,9 @@ function Rebuild-XcodeLaunchServicesDb { } function Build-ProvisionatorSymlink { - param( + param ( [Parameter(Mandatory)] - [string]$Version + [string] $Version ) $sourcePath = Get-XcodeRootPath -Version $Version @@ -222,9 +219,9 @@ function Build-ProvisionatorSymlink { } function Set-XcodeDeveloperDirEnvironmentVariables { - param( + param ( [Parameter(Mandatory)] - [string[]]$XcodeList + [string[]] $XcodeList ) $exactVersionsList = $XcodeList | Where-Object { Test-XcodeStableRelease -Version $_ } | ForEach-Object { @@ -246,3 +243,37 @@ function Set-XcodeDeveloperDirEnvironmentVariables { "export ${variableName}=${variableValue}" | Out-File "$env:HOME/.bashrc" -Append } } + +function Invoke-ValidateCommand { + param ( + [Parameter(Mandatory)] + [string] $Command, + [Uint] $Timeout = 0 + ) + + if ($Timeout -eq 0) { + $output = Invoke-Expression -Command $Command + if ($LASTEXITCODE -ne 0) { + throw "Command '$Command' has finished with exit code $LASTEXITCODE" + } + return $output + } else { + $job = $command | Start-Job -ScriptBlock { + $output = Invoke-Expression -Command $input + if ($LASTEXITCODE -ne 0) { + throw 'Command failed' + } + return $output + } + $waitObject = $job | Wait-Job -Timeout $Timeout + + if (-not $waitObject) { + throw "Command '$Command' has timed out" + } + + if ($waitObject.State -eq 'Failed') { + throw "Command '$Command' has failed" + } + Receive-Job -Job $job + } +} diff --git a/images/macos/scripts/tests/Android.Tests.ps1 b/images/macos/scripts/tests/Android.Tests.ps1 index 335fb7e0e..6f73c9a3f 100644 --- a/images/macos/scripts/tests/Android.Tests.ps1 +++ b/images/macos/scripts/tests/Android.Tests.ps1 @@ -6,9 +6,9 @@ $os = Get-OSVersion Describe "Android" { $androidSdkManagerPackages = Get-AndroidPackages - [int]$platformMinVersion = Get-ToolsetValue "android.platform_min_version" - [version]$buildToolsMinVersion = Get-ToolsetValue "android.build_tools_min_version" - [array]$ndkVersions = Get-ToolsetValue "android.ndk.versions" + [int]$platformMinVersion = (Get-ToolsetContent).android.platform_min_version + [version]$buildToolsMinVersion = (Get-ToolsetContent).android.build_tools_min_version + [array]$ndkVersions = (Get-ToolsetContent).android.ndk.versions $ndkFullVersions = $ndkVersions | ForEach-Object { Get-ChildItem "$env:ANDROID_HOME/ndk/${_}.*" -Name | Select-Object -Last 1 } | ForEach-Object { "ndk/${_}" } # Platforms starting with a letter are the preview versions, which is not installed on the image $platformVersionsList = ($androidSdkManagerPackages | Where-Object { "$_".StartsWith("platforms;") }) -replace 'platforms;android-', '' | Where-Object { $_ -match "^\d" } | Sort-Object -Unique @@ -25,9 +25,9 @@ Describe "Android" { $platformsInstalled, $buildTools, $ndkFullVersions, - (Get-ToolsetValue "android.extra-list" | ForEach-Object { "extras/${_}" }), - (Get-ToolsetValue "android.addon-list" | ForEach-Object { "add-ons/${_}" }), - (Get-ToolsetValue "android.additional-tools") + ((Get-ToolsetContent).android.extras | ForEach-Object { "extras/${_}" }), + ((Get-ToolsetContent).android.addons | ForEach-Object { "add-ons/${_}" }), + ((Get-ToolsetContent).android.additional_tools) ) | ForEach-Object { $_ } # Remove empty strings from array to avoid possible issues @@ -36,10 +36,10 @@ Describe "Android" { BeforeAll { $ANDROID_SDK_DIR = Join-Path $env:HOME "Library" "Android" "sdk" - function Validate-AndroidPackage { + function Confirm-AndroidPackage { param ( [Parameter(Mandatory = $true)] - [string]$PackageName + [string] $PackageName ) # Convert 'm2repository;com;android;support;constraint;constraint-layout-solver;1.0.0-beta1' -> @@ -76,7 +76,7 @@ Describe "Android" { It "" -TestCases $testCases { param ([string] $PackageName) - Validate-AndroidPackage $PackageName + Confirm-AndroidPackage $PackageName } } } diff --git a/images/macos/scripts/tests/BasicTools.Tests.ps1 b/images/macos/scripts/tests/BasicTools.Tests.ps1 index 9b49c75ca..9e65f7845 100644 --- a/images/macos/scripts/tests/BasicTools.Tests.ps1 +++ b/images/macos/scripts/tests/BasicTools.Tests.ps1 @@ -1,4 +1,5 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1" + $os = Get-OSVersion Describe "Azure CLI" { @@ -173,7 +174,7 @@ Describe "Homebrew" { Describe "Kotlin" { $kotlinPackages = @("kapt", "kotlin", "kotlinc", "kotlinc-jvm", "kotlin-dce-js") - It " is available" -TestCases ($kotlinPackages | ForEach-Object { @{ toolName = $_ } }) { + It " is available" -TestCases ($kotlinPackages | ForEach-Object { @{ toolName = $_ } }) { "$toolName -version" | Should -ReturnZeroExitCode } } diff --git a/images/macos/scripts/tests/Browsers.Tests.ps1 b/images/macos/scripts/tests/Browsers.Tests.ps1 index 61c8baaec..95545a50f 100644 --- a/images/macos/scripts/tests/Browsers.Tests.ps1 +++ b/images/macos/scripts/tests/Browsers.Tests.ps1 @@ -1,4 +1,5 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1" + $os = Get-OSVersion Describe "Chrome" { diff --git a/images/macos/scripts/tests/Common.Tests.ps1 b/images/macos/scripts/tests/Common.Tests.ps1 index de8f6aef9..720fdd5c8 100644 --- a/images/macos/scripts/tests/Common.Tests.ps1 +++ b/images/macos/scripts/tests/Common.Tests.ps1 @@ -10,7 +10,7 @@ Describe ".NET" { } Describe "GCC" { - $testCases = Get-ToolsetValue -KeyPath gcc.versions | ForEach-Object { @{Version = $_ } } + $testCases = (Get-ToolsetContent).gcc.versions | ForEach-Object { @{Version = $_ } } It "GCC " -TestCases $testCases { param ( @@ -60,7 +60,7 @@ Describe "AzCopy" { Describe "Miniconda" -Skip:($os.IsVentura -or $os.IsSonoma) { It "Conda" { - Get-EnvironmentVariable "CONDA" | Should -Not -BeNullOrEmpty + [System.Environment]::GetEnvironmentVariable("CONDA") | Should -Not -BeNullOrEmpty $condaBinPath = Join-Path $env:CONDA "bin" "conda" "$condaBinPath --version" | Should -ReturnZeroExitCode } @@ -79,8 +79,8 @@ Describe "CocoaPods" { } Describe "VSMac" -Skip:($os.IsVentura -or $os.IsSonoma) { - $vsMacVersions = Get-ToolsetValue "xamarin.vsmac.versions" - $defaultVSMacVersion = Get-ToolsetValue "xamarin.vsmac.default" + $vsMacVersions = (Get-ToolsetContent).xamarin.vsmac.versions + $defaultVSMacVersion = (Get-ToolsetContent).xamarin.vsmac.default $testCases = $vsMacVersions | ForEach-Object { $vsPath = "/Applications/Visual Studio $_.app" diff --git a/images/macos/scripts/tests/Databases.Tests.ps1 b/images/macos/scripts/tests/Databases.Tests.ps1 index 68c0fd390..0c8a7e7d7 100644 --- a/images/macos/scripts/tests/Databases.Tests.ps1 +++ b/images/macos/scripts/tests/Databases.Tests.ps1 @@ -7,14 +7,14 @@ Describe "MongoDB" -Skip:($os.IsVentura -or $os.IsSonoma) { @{ ToolName = "mongo" } @{ ToolName = "mongod" } ) { - $toolsetVersion = Get-ToolsetValue 'mongodb.version' + $toolsetVersion = (Get-ToolsetContent).mongodb.version (&$ToolName --version)[2].Split('"')[-2] | Should -BeLike "$toolsetVersion*" } } Describe "PostgreSQL" -Skip:($os.IsVentura -or $os.IsSonoma) { It "PostgreSQL version should correspond to the version in the toolset" { - $toolsetVersion = Get-ToolsetValue 'postgresql.version' + $toolsetVersion = (Get-ToolsetContent).postgresql.version # Client version (psql --version).split()[-2] | Should -BeLike "$toolsetVersion*" # Server version diff --git a/images/macos/scripts/tests/Git.Tests.ps1 b/images/macos/scripts/tests/Git.Tests.ps1 index 2a9f731e4..e88bf6bb5 100644 --- a/images/macos/scripts/tests/Git.Tests.ps1 +++ b/images/macos/scripts/tests/Git.Tests.ps1 @@ -1,5 +1,5 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1" -$os = Get-OSVersion + Describe "Git" { It "git is installed" { "git --version" | Should -ReturnZeroExitCode diff --git a/images/macos/scripts/tests/Haskell.Tests.ps1 b/images/macos/scripts/tests/Haskell.Tests.ps1 index dbfc402bd..bc2b6e507 100644 --- a/images/macos/scripts/tests/Haskell.Tests.ps1 +++ b/images/macos/scripts/tests/Haskell.Tests.ps1 @@ -1,4 +1,5 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1" + $os = Get-OSVersion Describe "Haskell" -Skip:($os.IsVentura -or $os.IsSonoma) { diff --git a/images/macos/scripts/tests/Helpers.psm1 b/images/macos/scripts/tests/Helpers.psm1 index 5f6fa593c..56d689c2c 100644 --- a/images/macos/scripts/tests/Helpers.psm1 +++ b/images/macos/scripts/tests/Helpers.psm1 @@ -1,11 +1,6 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1" -# Validates that tool is installed and in PATH -function Validate-ToolExist($tool) { - Get-Command $tool -ErrorAction SilentlyContinue | Should -BeTrue -} - -function Validate-ArrayWithoutDuplicates { +function Confirm-ArrayWithoutDuplicates { param ( [AllowEmptyCollection()] [Parameter(Mandatory = $true)] @@ -19,7 +14,7 @@ function Validate-ArrayWithoutDuplicates { } } -function Validate-Url { +function Confirm-UrlAvailability { param ( [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] @@ -37,7 +32,7 @@ function Validate-Url { $result | Should -BeTrue -Because "'$Url' should be available, but it is not" } -function Validate-IdenticalFileContent { +function Confirm-IdenticalFileContent { param ( [Parameter(Mandatory)] [string] $File1, @@ -54,7 +49,7 @@ function Validate-IdenticalFileContent { } function ShouldReturnZeroExitCode { - Param( + Param ( [String] $ActualValue, [switch] $Negate, [string] $Because # This parameter is unused by we need it to match Pester asserts signature @@ -65,8 +60,7 @@ function ShouldReturnZeroExitCode { [bool]$succeeded = $result.ExitCode -eq 0 if ($Negate) { $succeeded = -not $succeeded } - if (-not $succeeded) - { + if (-not $succeeded) { $commandOutputIndent = " " * 4 $commandOutput = ($result.Output | ForEach-Object { "${commandOutputIndent}${_}" }) -join "`n" $failureMessage = "Command '${ActualValue}' has finished with exit code ${actualExitCode}`n${commandOutput}" @@ -79,7 +73,7 @@ function ShouldReturnZeroExitCode { } function ShouldMatchCommandOutput { - Param( + Param ( [String] $ActualValue, [String] $RegularExpression, [switch] $Negate @@ -115,7 +109,7 @@ If (Get-Command -Name Add-ShouldOperator -ErrorAction SilentlyContinue) { } function Invoke-PesterTests { - Param( + Param ( [Parameter(Mandatory)][string] $TestFile, [string] $TestName ) diff --git a/images/macos/scripts/tests/Java.Tests.ps1 b/images/macos/scripts/tests/Java.Tests.ps1 index fb2e948f9..148b046d1 100644 --- a/images/macos/scripts/tests/Java.Tests.ps1 +++ b/images/macos/scripts/tests/Java.Tests.ps1 @@ -14,7 +14,7 @@ function Get-NativeVersionFormat { Describe "Java" { BeforeAll { - function Validate-JavaVersion { + function Confirm-JavaVersion { param($JavaCommand, $ExpectedVersion) $commandResult = Get-CommandResult $JavaCommand @@ -26,7 +26,7 @@ Describe "Java" { } } - $toolsetJava = Get-ToolsetValue "java" + $toolsetJava = (Get-ToolsetContent).java $defaultVersion = $toolsetJava.$arch.default $jdkVersions = $toolsetJava.$arch.versions @@ -44,14 +44,14 @@ Describe "Java" { } It "Java " -TestCases $_ { - $envVariablePath = Get-EnvironmentVariable $EnvVariable + $envVariablePath = [System.Environment]::GetEnvironmentVariable($EnvVariable) $javaBinPath = Join-Path $envVariablePath "/bin/java" - Validate-JavaVersion -JavaCommand "$javaBinPath -version" -ExpectedVersion $Version + Confirm-JavaVersion -JavaCommand "$javaBinPath -version" -ExpectedVersion $Version } if ($_.Title -eq "Default") { It "Version is default" -TestCases $_ { - Validate-JavaVersion -JavaCommand "java -version" -ExpectedVersion $Version + Confirm-JavaVersion -JavaCommand "java -version" -ExpectedVersion $Version } } } diff --git a/images/macos/scripts/tests/LLVM.Tests.ps1 b/images/macos/scripts/tests/LLVM.Tests.ps1 index 964718e78..9996b8600 100644 --- a/images/macos/scripts/tests/LLVM.Tests.ps1 +++ b/images/macos/scripts/tests/LLVM.Tests.ps1 @@ -2,7 +2,7 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1" Describe "Clang/LLVM" { BeforeAll { - $toolsetVersion = Get-ToolsetValue 'llvm.version' + $toolsetVersion = (Get-ToolsetContent).llvm.version } It "Clang/LLVM is installed and version is correct" { diff --git a/images/macos/scripts/tests/Node.Tests.ps1 b/images/macos/scripts/tests/Node.Tests.ps1 index 7e3757fae..aa68e83cb 100644 --- a/images/macos/scripts/tests/Node.Tests.ps1 +++ b/images/macos/scripts/tests/Node.Tests.ps1 @@ -9,7 +9,7 @@ Describe "Node.js" { } It "Node.js version should correspond to the version in the toolset" { - node --version | Should -BeLike "v$(Get-ToolsetValue 'node.default')*" + node --version | Should -BeLike "v$((Get-ToolsetContent).node.default)*" } It "NPM is installed" { @@ -33,7 +33,7 @@ Describe "nvm" -Skip:($os.IsVentura -or $os.IsSonoma) { } Context "nvm versions" { - [array]$nvmVersions = Get-ToolsetValue 'node.nvm_versions' + [array]$nvmVersions = (Get-ToolsetContent).node.nvm_versions $testCases = $nvmVersions | ForEach-Object { @{NvmVersion = $_} } It "" -TestCases $testCases { @@ -47,7 +47,7 @@ Describe "nvm" -Skip:($os.IsVentura -or $os.IsSonoma) { } Describe "Global NPM Packages" { - $globalNpmPackages = Get-ToolsetValue "npm.global_packages" + $globalNpmPackages = (Get-ToolsetContent).npm.global_packages $globalNpmPackagesWithTests = $globalNpmPackages | Where-Object { $_.test } | ForEach-Object { @{ Name = $_.name; Test = $_.test } } It "" -TestCases $globalNpmPackagesWithTests { diff --git a/images/macos/scripts/tests/OpenSSL.Tests.ps1 b/images/macos/scripts/tests/OpenSSL.Tests.ps1 index 4b74b2603..1fb8886a8 100644 --- a/images/macos/scripts/tests/OpenSSL.Tests.ps1 +++ b/images/macos/scripts/tests/OpenSSL.Tests.ps1 @@ -13,7 +13,7 @@ Describe "OpenSSL" { $openSSLpath | Should -Exist } } - + Context "OpenSSL 1.1 is default" { It "Default OpenSSL version is 1.1" { $commandResult = Get-CommandResult "openssl version" diff --git a/images/macos/scripts/tests/PHP.Tests.ps1 b/images/macos/scripts/tests/PHP.Tests.ps1 index fb063da39..c87b36bb4 100644 --- a/images/macos/scripts/tests/PHP.Tests.ps1 +++ b/images/macos/scripts/tests/PHP.Tests.ps1 @@ -1,13 +1,14 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1" + $os = Get-OSVersion Describe "PHP" { Context "PHP" -Skip:($os.IsVenturaArm64 -or $os.IsSonomaArm64) { It "PHP Path" { - Get-WhichTool "php" | Should -Not -BeLike "/usr/bin/php*" + Get-ToolPath "php" | Should -Not -BeLike "/usr/bin/php*" } It "PHP version" { - $phpVersionToolset = Get-ToolsetValue 'php.version' + $phpVersionToolset = (Get-ToolsetContent).php.version $phpInstalledVersion = php --version | Out-String | Select-String "${phpVersionToolset}" $phpInstalledVersion | Should -BeLike "PHP ${phpVersionToolset}*" } diff --git a/images/macos/scripts/tests/PipxPackages.Tests.ps1 b/images/macos/scripts/tests/PipxPackages.Tests.ps1 index ec47311f4..bb7bdc10e 100644 --- a/images/macos/scripts/tests/PipxPackages.Tests.ps1 +++ b/images/macos/scripts/tests/PipxPackages.Tests.ps1 @@ -4,7 +4,7 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1" $os = Get-OSVersion Describe "PipxPackages" -Skip:($os.IsVentura -or $os.IsSonoma) { - $pipxToolset = Get-ToolsetValue "pipx" + $pipxToolset = (Get-ToolsetContent).pipx $testCases = $pipxToolset | ForEach-Object { @{package = $_.package; cmd = $_.cmd} } It "" -TestCases $testCases { "$cmd" | Should -ReturnZeroExitCode diff --git a/images/macos/scripts/tests/Powershell.Tests.ps1 b/images/macos/scripts/tests/Powershell.Tests.ps1 index fa4c6e2a5..2892c2400 100644 --- a/images/macos/scripts/tests/Powershell.Tests.ps1 +++ b/images/macos/scripts/tests/Powershell.Tests.ps1 @@ -9,7 +9,7 @@ Describe "Powershell" { } Context "Powershell Modules" { - $modules = Get-ToolsetValue powershellModules + $modules = (Get-ToolsetContent).powershellModules $withoutVersionsModules = $modules | Where-Object {-not $_.versions} | ForEach-Object { @{moduleName = $_.name} } @@ -20,7 +20,7 @@ Describe "Powershell" { @{moduleName = $moduleName; expectedVersion = $_} } } - + It " is installed" -TestCases $withoutVersionsModules { param ( [string] $moduleName @@ -28,7 +28,7 @@ Describe "Powershell" { Get-Module -Name $moduleName -ListAvailable | Should -BeTrue } - + if ($withVersionsModules) { It " with is installed" -TestCases $withVersionsModules { param ( diff --git a/images/macos/scripts/tests/Python.Tests.ps1 b/images/macos/scripts/tests/Python.Tests.ps1 index 84e85a08e..c60d57082 100644 --- a/images/macos/scripts/tests/Python.Tests.ps1 +++ b/images/macos/scripts/tests/Python.Tests.ps1 @@ -9,7 +9,7 @@ Describe "Python3" -Skip:($os.IsVenturaArm64 -or $os.IsSonomaArm64) { } It "Python 3 is installed under /usr/local/bin" { - Get-WhichTool "python3" | Should -BeLike "/usr/local/bin*" + Get-ToolPath "python3" | Should -BeLike "/usr/local/bin*" } It "Pip 3 is available" { diff --git a/images/macos/scripts/tests/Ruby.arm64.Tests.ps1 b/images/macos/scripts/tests/Ruby.arm64.Tests.ps1 index 64873954e..45cc879f1 100644 --- a/images/macos/scripts/tests/Ruby.arm64.Tests.ps1 +++ b/images/macos/scripts/tests/Ruby.arm64.Tests.ps1 @@ -9,14 +9,14 @@ Describe "Ruby" -Skip:(-not $os.IsArm64) { } It "Ruby is installed via HomeBrew" { - Get-WhichTool "ruby" | Should -Not -BeLike "/usr/bin/ruby*" + Get-ToolPath "ruby" | Should -Not -BeLike "/usr/bin/ruby*" } It "Ruby tools are consistent" { $expectedPrefix = "/opt/homebrew" - Get-WhichTool "ruby" | Should -Match "$($expectedPrefix)*" - Get-WhichTool "gem" | Should -Match "$($expectedPrefix)*" - Get-WhichTool "bundler" | Should -Match "$($expectedPrefix)*" + Get-ToolPath "ruby" | Should -Match "$($expectedPrefix)*" + Get-ToolPath "gem" | Should -Match "$($expectedPrefix)*" + Get-ToolPath "bundler" | Should -Match "$($expectedPrefix)*" } It "Ruby gems permissions are valid" { diff --git a/images/macos/scripts/tests/Ruby.x64.Tests.ps1 b/images/macos/scripts/tests/Ruby.x64.Tests.ps1 index ded146dd4..b458278b3 100644 --- a/images/macos/scripts/tests/Ruby.x64.Tests.ps1 +++ b/images/macos/scripts/tests/Ruby.x64.Tests.ps1 @@ -9,14 +9,14 @@ Describe "Ruby" -Skip:($os.IsArm64) { } It "Ruby is installed via HomeBrew" { - Get-WhichTool "ruby" | Should -Not -BeLike "/usr/bin/ruby*" + Get-ToolPath "ruby" | Should -Not -BeLike "/usr/bin/ruby*" } It "Ruby tools are consistent" { $expectedPrefix = "/usr/local" - Get-WhichTool "ruby" | Should -Match "$($expectedPrefix)*" - Get-WhichTool "gem" | Should -Match "$($expectedPrefix)*" - Get-WhichTool "bundler" | Should -Match "$($expectedPrefix)*" + Get-ToolPath "ruby" | Should -Match "$($expectedPrefix)*" + Get-ToolPath "gem" | Should -Match "$($expectedPrefix)*" + Get-ToolPath "bundler" | Should -Match "$($expectedPrefix)*" } It "Ruby gems permissions are valid" { diff --git a/images/macos/scripts/tests/RubyGem.Tests.ps1 b/images/macos/scripts/tests/RubyGem.Tests.ps1 index fb07ce9be..f5ef6f155 100644 --- a/images/macos/scripts/tests/RubyGem.Tests.ps1 +++ b/images/macos/scripts/tests/RubyGem.Tests.ps1 @@ -1,13 +1,13 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1" + $os = Get-OSVersion Describe "RubyGems" { - $gemTestCases = Get-ToolsetValue -KeyPath "ruby.rubygems" | ForEach-Object { + $gemTestCases = (Get-ToolsetContent).ruby.rubygems | ForEach-Object { @{gemName = $_} } - if ($gemTestCases) - { + if ($gemTestCases) { It "Gem is installed" -TestCases $gemTestCases { "gem list -i '^$gemName$'" | Should -MatchCommandOutput "true" } diff --git a/images/macos/scripts/tests/Rust.Tests.ps1 b/images/macos/scripts/tests/Rust.Tests.ps1 index 72cb59a69..b5c1c53fc 100644 --- a/images/macos/scripts/tests/Rust.Tests.ps1 +++ b/images/macos/scripts/tests/Rust.Tests.ps1 @@ -1,4 +1,5 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1" + $os = Get-OSVersion Describe "Rust" { diff --git a/images/macos/scripts/tests/Toolcache.Tests.ps1 b/images/macos/scripts/tests/Toolcache.Tests.ps1 index e2b1a7226..4f57962ec 100644 --- a/images/macos/scripts/tests/Toolcache.Tests.ps1 +++ b/images/macos/scripts/tests/Toolcache.Tests.ps1 @@ -6,7 +6,7 @@ $os = Get-OSVersion Describe "Toolcache" { $toolcacheDirectory = Join-Path $env:HOME "hostedtoolcache" - [array]$packages += Get-ToolsetValue -KeyPath "toolcache" | ForEach-Object { + [array]$packages += (Get-ToolsetContent).toolcache | ForEach-Object { return [PSCustomObject] @{ ToolName = ($_.name).ToLower() Arch = $arch diff --git a/images/macos/scripts/tests/Toolset.Tests.ps1 b/images/macos/scripts/tests/Toolset.Tests.ps1 index 5baef2044..f2aa3cd7a 100644 --- a/images/macos/scripts/tests/Toolset.Tests.ps1 +++ b/images/macos/scripts/tests/Toolset.Tests.ps1 @@ -39,83 +39,82 @@ $toolsets | ForEach-Object { It "Version '$vsmacVersion' is available and can be downloaded" { $vsmacUrl = Invoke-BashUtilsFunction("buildVSMacDownloadUrl", $vsmacVersion) - Validate-Url $vsmacUrl + Confirm-UrlAvailability $vsmacUrl } } Context "Mono" { - $sdkVersions = $toolset.xamarin."mono-versions" + $sdkVersions = $toolset.xamarin.mono_versions $sdkVersions | ForEach-Object { It "Version '$_' is available and can be downloaded" { $sdkUrl = Invoke-BashUtilsFunction("buildMonoDownloadUrl", $_) - Validate-Url $sdkUrl + Confirm-UrlAvailability $sdkUrl } } It "Version list doesn't contain versions with the same major/minor version" { $versions = $sdkVersions | ForEach-Object { Get-ShortVersion $_ } - Validate-ArrayWithoutDuplicates $versions -Because "It doesn't allow to install more than one version with the same major/minor" + Confirm-ArrayWithoutDuplicates $versions -Because "It doesn't allow to install more than one version with the same major/minor" } } Context "Xamarin.iOS" { - $sdkVersions = $toolset.xamarin."ios-versions" + $sdkVersions = $toolset.xamarin.ios_versions $sdkVersions | ForEach-Object { It "Version '$_' is available and can be downloaded" { $sdkUrl = Invoke-BashUtilsFunction("buildXamariniIOSDownloadUrl", $_) - Validate-Url $sdkUrl + Confirm-UrlAvailability $sdkUrl } } It "Version list doesn't contain versions with the same major/minor version" { $versions = $sdkVersions | ForEach-Object { Get-ShortVersion $_ } - Validate-ArrayWithoutDuplicates $versions -Because "It doesn't allow to install more than one version with the same major/minor" + Confirm-ArrayWithoutDuplicates $versions -Because "It doesn't allow to install more than one version with the same major/minor" } } Context "Xamarin.Mac" { - $sdkVersions = $toolset.xamarin."mac-versions" + $sdkVersions = $toolset.xamarin.mac_versions $sdkVersions | ForEach-Object { It "Version '$_' is available and can be downloaded" { $sdkUrl = Invoke-BashUtilsFunction("buildXamarinMacDownloadUrl", $_) - Validate-Url $sdkUrl + Confirm-UrlAvailability $sdkUrl } } It "Version list doesn't contain versions with the same major/minor version" { $versions = $sdkVersions | ForEach-Object { Get-ShortVersion $_ } - Validate-ArrayWithoutDuplicates $versions -Because "It doesn't allow to install more than one version with the same major/minor" + Confirm-ArrayWithoutDuplicates $versions -Because "It doesn't allow to install more than one version with the same major/minor" } } Context "Xamarin.Android" { - $sdkVersions = $toolset.xamarin."android-versions" + $sdkVersions = $toolset.xamarin.android_versions $sdkVersions | ForEach-Object { It "Version '$_' is available and can be downloaded" { $sdkUrl = Invoke-BashUtilsFunction("buildXamarinAndroidDownloadUrl", $_) - Validate-Url $sdkUrl + Confirm-UrlAvailability $sdkUrl } } It "Version list doesn't contain versions with the same major/minor version" { $versions = $sdkVersions | ForEach-Object { $_.Replace("-", ".") } | ForEach-Object { Get-ShortVersion $_ } - Validate-ArrayWithoutDuplicates $versions -Because "It doesn't allow to install more than one version with the same major/minor" + Confirm-ArrayWithoutDuplicates $versions -Because "It doesn't allow to install more than one version with the same major/minor" } } Context "Xamarin bundles" { - $monoVersions = $toolset.xamarin."mono-versions" | ForEach-Object { Get-ShortVersion $_ } - $iOSVersions = $toolset.xamarin."ios-versions" | ForEach-Object { Get-ShortVersion $_ } - $macVersions = $toolset.xamarin."mac-versions" | ForEach-Object { Get-ShortVersion $_ } + $monoVersions = $toolset.xamarin.mono_versions | ForEach-Object { Get-ShortVersion $_ } + $iOSVersions = $toolset.xamarin.ios_versions | ForEach-Object { Get-ShortVersion $_ } + $macVersions = $toolset.xamarin.mac_versions | ForEach-Object { Get-ShortVersion $_ } # Old Xamarin.Android version looks like "9.0.0-18" that doesn't support by System.Version - $androidVersions = $toolset.xamarin."android-versions" | ForEach-Object { Get-ShortVersion $_.Replace("-", ".") } - - + $androidVersions = $toolset.xamarin.android_versions | ForEach-Object { Get-ShortVersion $_.Replace("-", ".") } $bundles = $toolset.xamarin.bundles + $bundles | ForEach-Object { It "'$($_.symlink)' is valid" { $monoVersions | Should -Contain $_.mono @@ -127,18 +126,16 @@ $toolsets | ForEach-Object { It "Each bundle has unique symlink" { $symlinks = $bundles | ForEach-Object { $_.symlink } - Validate-ArrayWithoutDuplicates $symlinks -Because "Bundle symlinks should be unique" + Confirm-ArrayWithoutDuplicates $symlinks -Because "Bundle symlinks should be unique" } It "Current bundle is valid" { - $currentBundleSymlink = $toolset.xamarin."bundle-default" + $currentBundleSymlink = $toolset.xamarin.bundle_default if ($currentBundleSymlink -ne "latest") { $bundleSymlinks = $bundles | ForEach-Object { $_.symlink } $bundleSymlinks | Should -Contain $currentBundleSymlink -Because "Current bundle should be installed" } - } - } } } diff --git a/images/macos/scripts/tests/Xamarin.Tests.ps1 b/images/macos/scripts/tests/Xamarin.Tests.ps1 index 501ade256..7796b4c59 100644 --- a/images/macos/scripts/tests/Xamarin.Tests.ps1 +++ b/images/macos/scripts/tests/Xamarin.Tests.ps1 @@ -2,16 +2,17 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1" Import-Module "$PSScriptRoot/Helpers.psm1" -DisableNameChecking $os = Get-OSVersion + if ($os.IsVentura -or $os.IsSonoma) { - $MONO_VERSIONS = @(Get-ToolsetValue "mono.framework.version") + $MONO_VERSIONS = @((Get-ToolsetContent).mono.framework.version) $XAMARIN_IOS_VERSIONS = @() $XAMARIN_MAC_VERSIONS = @() $XAMARIN_ANDROID_VERSIONS = @() } elseif ($os.IsBigSur -or $os.IsMonterey) { - $MONO_VERSIONS = Get-ToolsetValue "xamarin.mono-versions" - $XAMARIN_IOS_VERSIONS = Get-ToolsetValue "xamarin.ios-versions" - $XAMARIN_MAC_VERSIONS = Get-ToolsetValue "xamarin.mac-versions" - $XAMARIN_ANDROID_VERSIONS = Get-ToolsetValue "xamarin.android-versions" + $MONO_VERSIONS = (Get-ToolsetContent).xamarin.mono_versions + $XAMARIN_IOS_VERSIONS = (Get-ToolsetContent).xamarin.ios_versions + $XAMARIN_MAC_VERSIONS = (Get-ToolsetContent).xamarin.mac_versions + $XAMARIN_ANDROID_VERSIONS = (Get-ToolsetContent).xamarin.android_versions } BeforeAll { @@ -53,7 +54,7 @@ Describe "Mono" { $shortVersionPath = Join-Path $shortSymlinkFolderPath "VERSION" $fullVersionPath = Join-Path $VersionFolderPath "VERSION" - Validate-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath + Confirm-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath } It "NUnit console is installed" -TestCases $testCase { @@ -116,7 +117,7 @@ Describe "Xamarin.iOS" -Skip:($os.IsVentura -or $os.IsSonoma) { $shortVersionPath = Join-Path $shortSymlinkFolderPath "VERSION" $fullVersionPath = Join-Path $VersionFolderPath "VERSION" - Validate-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath + Confirm-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath } } } @@ -149,7 +150,7 @@ Describe "Xamarin.Mac" -Skip:($os.IsVentura -or $os.IsSonoma) { $shortVersionPath = Join-Path $shortSymlinkFolderPath "VERSION" $fullVersionPath = Join-Path $VersionFolderPath "VERSION" - Validate-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath + Confirm-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath } } } @@ -181,7 +182,7 @@ Describe "Xamarin.Android" -Skip:($os.IsVentura -or $os.IsSonoma) { $shortVersionPath = Join-Path $shortSymlinkFolderPath "VERSION" $fullVersionPath = Join-Path $VersionFolderPath "VERSION" - Validate-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath + Confirm-IdenticalFileContent -File1 $shortVersionPath -File2 $fullVersionPath } It "has correct symlinks" -TestCases $testCase { @@ -205,8 +206,8 @@ Describe "Xamarin Bundles" -Skip:($os.IsVentura -or $os.IsSonoma) { If ($XAMARIN_BUNDLES.Count -eq 0) { return } # Skip this test if there are no bundles - [array]$XAMARIN_BUNDLES = Get-ToolsetValue "xamarin.bundles" - $XAMARIN_DEFAULT_BUNDLE = Get-ToolsetValue "xamarin.bundle-default" + [array]$XAMARIN_BUNDLES = (Get-ToolsetContent).xamarin.bundles + $XAMARIN_DEFAULT_BUNDLE = (Get-ToolsetContent).xamarin.bundle_default If ($XAMARIN_DEFAULT_BUNDLE -eq "latest") { $XAMARIN_DEFAULT_BUNDLE = $XAMARIN_BUNDLES[0].symlink } $currentBundle = [PSCustomObject] @{ @@ -244,7 +245,7 @@ Describe "Xamarin Bundles" -Skip:($os.IsVentura -or $os.IsSonoma) { $sourceVersionPath = Join-Path $MONO_VERSIONS_PATH $BundleMono "VERSION" $targetVersionPath = Join-Path $MONO_VERSIONS_PATH $BundleSymlink "VERSION" - Validate-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath + Confirm-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath } It "iOS symlink exists" -TestCases $allBundles { @@ -262,7 +263,7 @@ Describe "Xamarin Bundles" -Skip:($os.IsVentura -or $os.IsSonoma) { $sourceVersionPath = Join-Path $XAMARIN_IOS_VERSIONS_PATH $BundleIos "VERSION" $targetVersionPath = Join-Path $XAMARIN_IOS_VERSIONS_PATH $BundleSymlink "VERSION" - Validate-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath + Confirm-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath } It "Mac symlink exists" -TestCases $allBundles { @@ -280,7 +281,7 @@ Describe "Xamarin Bundles" -Skip:($os.IsVentura -or $os.IsSonoma) { $sourceVersionPath = Join-Path $XAMARIN_MAC_VERSIONS_PATH $BundleMac "VERSION" $targetVersionPath = Join-Path $XAMARIN_MAC_VERSIONS_PATH $BundleSymlink "VERSION" - Validate-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath + Confirm-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath } It "Xamarin.Android symlink exists" -TestCases $allBundles { @@ -298,7 +299,7 @@ Describe "Xamarin Bundles" -Skip:($os.IsVentura -or $os.IsSonoma) { $sourceVersionPath = Join-Path $XAMARIN_ANDROID_VERSIONS_PATH $BundleAndroid "VERSION" $targetVersionPath = Join-Path $XAMARIN_ANDROID_VERSIONS_PATH $BundleSymlink "VERSION" - Validate-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath + Confirm-IdenticalFileContent -File1 $targetVersionPath -File2 $sourceVersionPath } } diff --git a/images/macos/scripts/tests/Xcode.Tests.ps1 b/images/macos/scripts/tests/Xcode.Tests.ps1 index 6ef32baac..912fccb7f 100644 --- a/images/macos/scripts/tests/Xcode.Tests.ps1 +++ b/images/macos/scripts/tests/Xcode.Tests.ps1 @@ -2,14 +2,20 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1" Import-Module "$PSScriptRoot/../helpers/Xcode.Helpers.psm1" Import-Module "$PSScriptRoot/Helpers.psm1" -DisableNameChecking -$ARCH = Get-Architecture -$xcodeVersions = Get-ToolsetValue "xcode.$ARCH.versions" -$defaultXcode = Get-ToolsetValue "xcode.default" +$arch = Get-Architecture +$xcodeVersions = (Get-ToolsetContent).xcode.${arch}.versions +$defaultXcode = (Get-ToolsetContent).xcode.default $latestXcodeVersion = $xcodeVersions | Select-Object -First 1 $os = Get-OSVersion Describe "Xcode" { - $testCases = $xcodeVersions | ForEach-Object { @{ XcodeVersion = $_.link; LatestXcodeVersion = $xcodeVersions[0].link; Symlinks = $_.symlinks } } + $testCases = $xcodeVersions | ForEach-Object { + @{ + XcodeVersion = $_.link; + LatestXcodeVersion = $xcodeVersions[0].link; + Symlinks = $_.symlinks + } + } Context "Versions" { It "" -TestCases $testCases { @@ -82,7 +88,7 @@ Describe "XCODE_DEVELOPER_DIR variables" { It "XCODE__DEVELOPER_DIR" -TestCases $testCases { $variableName = "XCODE_${MajorVersion}_DEVELOPER_DIR" - $actualPath = Get-EnvironmentVariable $variableName + $actualPath = [System.Environment]::GetEnvironmentVariable($variableName) $expectedVersion = $VersionsList | Where-Object { $_.Version.Major -eq $MajorVersion } | Select-Object -First 1 $expectedPath = "$($expectedVersion.RootPath)/Contents/Developer" $actualPath | Should -Exist @@ -99,21 +105,13 @@ Describe "Xcode simulators" { [array]$devicesList = @(Get-XcodeDevicesList | Where-Object { $_ }) Write-Host "Devices for $XcodeVersion" Write-Host ($devicesList -join "`n") - Validate-ArrayWithoutDuplicates $devicesList -Because "Found duplicate device simulators" + Confirm-ArrayWithoutDuplicates $devicesList -Because "Found duplicate device simulators" } - -# It "No duplicates in pairs" -TestCases $testCase { -# Switch-Xcode -Version $XcodeVersion -# [array]$pairsList = @(Get-XcodePairsList | Where-Object { $_ }) -# Write-Host "Pairs for $XcodeVersion" -# Write-Host ($pairsList -join "`n") -# Validate-ArrayWithoutDuplicates $pairsList -Because "Found duplicate pairs simulators" -# } } } AfterEach { - $defaultXcode = Get-ToolsetValue "xcode.default" + $defaultXcode = (Get-ToolsetContent).xcode.default Switch-Xcode -Version $defaultXcode } } diff --git a/images/macos/toolsets/Readme.md b/images/macos/toolsets/Readme.md index 14453889a..1ac8e98c1 100644 --- a/images/macos/toolsets/Readme.md +++ b/images/macos/toolsets/Readme.md @@ -1,22 +1,26 @@ # Toolset JSON structure + ## Xcode + - `versions` - the array of objects that will present installed Xcode versions - - `link` property points to the place where Xcode will be located on image. `/Applications/Xcode_.app` - - `version` points to Xcode version that will be downloaded and installed - - `symlinks` describes the list of aliases where symlinks will be created to + - `link` property points to the place where Xcode will be located on image. `/Applications/Xcode_.app` + - `version` points to Xcode version that will be downloaded and installed + - `symlinks` describes the list of aliases where symlinks will be created to - `default` - version of Xcode to set as default (should be metched with any `link` in `versions` property) **Example:** `"11.2"` **Note:** + - If `version` is specified with spaces, it is considered as exact Xcode name like `12.1.1 Release Candidate`. - If `version` doesn't contain spaces, the latest version will be resolved with the following priority: - - stable version like `12.1` - - release candidate version like `12.1 Release Candidate N` (the latest N will be chosen) - - GM version like `12.1 GM Seed N` (the latest N will be chosen) - - beta version like `12.1 beta N` (the latest N will be chosen) + - stable version like `12.1` + - release candidate version like `12.1 Release Candidate N` (the latest N will be chosen) + - GM version like `12.1 GM Seed N` (the latest N will be chosen) + - beta version like `12.1 beta N` (the latest N will be chosen) **Example:** -``` + +```json "versions": [ { "link": "12.2", "version": "12.2.0" }, { "link": "11.7", "version": "11.7.0", "symlinks": ["11.7_beta"] } @@ -24,27 +28,26 @@ ``` ## Xamarin + - `vsmac` - version of Visual Studio For Mac to install. **Example:** `"8.3.11.1"` -- `mono-versions` - the array of Mono versions to install. +- `mono_versions` - the array of Mono versions to install. **Example:** `[ "6.4.0.208", "6.0.0.334" ]` -- `ios-versions` - the array of Xamarin iOS versions to install. +- `ios_versions` - the array of Xamarin iOS versions to install. **Example:** `[ "13.6.0.12", "13.4.0.2", "13.2.0.47" ]` -- `mac-versions` - the array of Xamarin iOS versions to install. +- `mac_versions` - the array of Xamarin iOS versions to install. **Example:** `[ "6.6.0.12", "6.4.0.2", "6.2.0.47" ]` -- `android-versions` - the array of Xamarin iOS versions to install. +- `android_versions` - the array of Xamarin iOS versions to install. **Example:** `[ "10.0.6.2", "9.4.1.0" ]` -**Note:** More than one version of SDK with the same major.minor version should not be installed. It applies to `mono-versions`, `ios-versions`, `mac-versions`, `android-versions` fields. +**Note:** More than one version of SDK with the same major.minor version should not be installed. It applies to `mono_versions`, `ios_versions`, `mac_versions`, `android_versions` fields. For example, if Mono `6.4.0.100` is installed and Mono `6.4.1.2` was released recently, we should not install both, just update `6.4.0.100` -> `6.4.1.2`. Only major and minor version changes can break backward compatibility so it is safe. - -
-- `bundle-default` - the symlink of the bundle that will be set as default on the image. +- `bundle_default` - the symlink of the bundle that will be set as default on the image. This bundle will be set as `Current`. **Example:** `"5_12_0"` (set bundle with symlink `5_12_0` as default) **Example:** `"latest"` (set latest bundle as default) @@ -59,9 +62,9 @@ The first bundle in the list will be as `Latest`. - `mac` - version of Xamarin.Mac that will be set in this bundle. Only two numbers (`major.minor`) should be specified. - `android` - version of Xamarin.Android that will be set in this bundle. Only two numbers (`major.minor`) should be specified. +**Example:** - **Example:** -``` +```json [ { "symlink": "6_4_2", @@ -81,19 +84,20 @@ The first bundle in the list will be as `Latest`. ``` ## Android + - `platform-list` - the array of android platforms to install. **Example:** `[ "android-29", "android-28", "android-27" ]` - `build-tools` - the array of android build tools to install. **Example:** `[ "29.0.2", "29.0.1", "29.0.0", "28.0.3" ]` -- `extra-list` - the array of android extra items to install. +- `extras` - the array of android extra items to install. **Example:** `[ "google;google_play_services", "intel;Hardware_Accelerated_Execution_Manager" ]` -- `addon-list` - the array of android addons to install. +- `addons` - the array of android addons to install. **Example:** `[ "addon-google_apis-google-24", "addon-google_apis-google-23" ]` +## Toolset JSON validation -# Toolset JSON validation File `Toolset.Tests.ps1` contains PowerShell [Pester](https://github.com/Pester/Pester) tests that validate JSON toolset files. -Type `Invoke-Pester` in the current folder in PowerShell to run tests. \ No newline at end of file +Type `Invoke-Pester` in the current folder in PowerShell to run tests. diff --git a/images/macos/toolsets/toolset-11.json b/images/macos/toolsets/toolset-11.json index c292e6fe9..a7b656d94 100644 --- a/images/macos/toolsets/toolset-11.json +++ b/images/macos/toolsets/toolset-11.json @@ -17,19 +17,19 @@ "default": "2022", "versions": [ "2019", "2022" ] }, - "mono-versions": [ + "mono_versions": [ "6.12.0.188" ], - "ios-versions": [ + "ios_versions": [ "15.8.0.3", "15.6.0.3", "15.4.0.0", "15.2.0.17", "15.0.0.6", "14.20.0.24", "14.16.0.5", "14.14.2.5", "14.10.0.4", "14.8.0.3", "14.6.0.15", "14.4.1.3", "14.2.0.12", "14.0.0.0", "13.20.2.2" ], - "mac-versions": [ + "mac_versions": [ "8.8.0.3", "8.6.0.3", "8.4.0.0", "8.2.0.17", "7.14.0.27", "7.10.0.5", "7.8.2.5", "7.4.0.10", "7.2.0.3", "7.0.0.15", "6.22.1.26", "6.20.2.2" ], - "android-versions": [ + "android_versions": [ "12.2.8.3", "12.1.0.2", "12.0.0.3", "11.3.0.4", "11.2.2.1", "11.1.0.26", "11.0.2.0" ], - "bundle-default": "6_12_12", + "bundle_default": "6_12_12", "bundles": [ { "symlink": "6_12_16", @@ -162,11 +162,11 @@ "cmdline-tools": "commandlinetools-mac-9123335_latest.zip", "platform_min_version": "27", "build_tools_min_version": "27.0.0", - "extra-list": [ + "extras": [ "android;m2repository", "google;m2repository", "google;google_play_services" ], - "addon-list": [], - "additional-tools": [ + "addons": [], + "additional_tools": [ "cmake;3.10.2.4988404", "cmake;3.18.1", "cmake;3.22.1" diff --git a/images/macos/toolsets/toolset-12.json b/images/macos/toolsets/toolset-12.json index 01fa8c30c..72e06fc76 100644 --- a/images/macos/toolsets/toolset-12.json +++ b/images/macos/toolsets/toolset-12.json @@ -18,19 +18,19 @@ "default": "2022", "versions": [ "2019", "2022" ] }, - "mono-versions": [ + "mono_versions": [ "6.12.0.188" ], - "ios-versions": [ + "ios_versions": [ "16.2.0.5", "16.1.1.27", "16.0.0.72", "15.12.0.2", "15.10.0.5", "15.8.0.3", "15.6.0.3", "15.4.0.0", "15.2.0.17", "15.0.0.6" ], - "mac-versions": [ + "mac_versions": [ "9.1.0.5", "9.0.0.27", "8.12.0.2", "8.10.0.5", "8.8.0.3", "8.6.0.3", "8.4.0.0", "8.2.0.17", "7.14.0.27" ], - "android-versions": [ + "android_versions": [ "13.2.1.2", "13.1.0.1", "13.0.0.0", "12.3.3.3", "12.2.8.3", "12.1.0.2", "12.0.0.3", "11.3.0.4" ], - "bundle-default": "6_12_21", + "bundle_default": "6_12_21", "bundles": [ { "symlink": "6_12_24", @@ -149,11 +149,11 @@ "cmdline-tools": "commandlinetools-mac-9123335_latest.zip", "platform_min_version": "27", "build_tools_min_version": "27.0.0", - "extra-list": [ + "extras": [ "android;m2repository", "google;m2repository", "google;google_play_services" ], - "addon-list": [], - "additional-tools": [ + "addons": [], + "additional_tools": [ "cmake;3.18.1", "cmake;3.22.1" ], diff --git a/images/macos/toolsets/toolset-13.json b/images/macos/toolsets/toolset-13.json index 3258b3dad..ced440632 100644 --- a/images/macos/toolsets/toolset-13.json +++ b/images/macos/toolsets/toolset-13.json @@ -33,11 +33,11 @@ "sdk-tools": "sdk-tools-darwin-4333796.zip", "platform_min_version": "33", "build_tools_min_version": "33.0.2", - "extra-list": [ + "extras": [ "android;m2repository", "google;m2repository", "google;google_play_services" ], - "addon-list": [], - "additional-tools": [ + "addons": [], + "additional_tools": [ "cmake;3.22.1" ], "ndk": { diff --git a/images/macos/toolsets/toolset-14.json b/images/macos/toolsets/toolset-14.json index d9ea4f71f..dbe70586d 100644 --- a/images/macos/toolsets/toolset-14.json +++ b/images/macos/toolsets/toolset-14.json @@ -29,11 +29,11 @@ "sdk-tools": "sdk-tools-darwin-4333796.zip", "platform_min_version": "33", "build_tools_min_version": "33.0.2", - "extra-list": [ + "extras": [ "android;m2repository", "google;m2repository", "google;google_play_services" ], - "addon-list": [], - "additional-tools": [ + "addons": [], + "additional_tools": [ "cmake;3.22.1" ], "ndk": {