diff --git a/images/macos/helpers/Xcode.Installer.psm1 b/images/macos/helpers/Xcode.Installer.psm1 index 97d4c132..a08ee3b5 100644 --- a/images/macos/helpers/Xcode.Installer.psm1 +++ b/images/macos/helpers/Xcode.Installer.psm1 @@ -175,6 +175,17 @@ function Build-XcodeSymlinks { } } +function Rebuild-XcodeLaunchServicesDb { + param( + [Parameter(Mandatory)] + [string]$Version + ) + + $xcodePath = Get-XcodeRootPath -Version $Version + $lsregister = '/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister' + Get-ChildItem -Recurse -Filter "*.app" $xcodePath | Foreach-Object { & $lsregister -f $_.FullName} +} + function Build-ProvisionatorSymlink { param( [Parameter(Mandatory)] @@ -216,4 +227,4 @@ function Set-XcodeDeveloperDirEnvironmentVariables { Write-Host "Set ${variableName}=${variableValue}" "export ${variableName}=${variableValue}" | Out-File "$env:HOME/.bashrc" -Append } -} \ No newline at end of file +} diff --git a/images/macos/provision/core/xcode.ps1 b/images/macos/provision/core/xcode.ps1 index ab984cd9..1f8ce717 100644 --- a/images/macos/provision/core/xcode.ps1 +++ b/images/macos/provision/core/xcode.ps1 @@ -51,6 +51,11 @@ $xcodeVersions | ForEach-Object { } } +Write-Host "Rebuilding Launch Services database ..." +$xcodeVersions | ForEach-Object { + Rebuild-XcodeLaunchServicesDb -Version $_.link +} + Write-Host "Setting default Xcode to $defaultXcode" Switch-Xcode -Version $defaultXcode New-Item -Path "/Applications/Xcode.app" -ItemType SymbolicLink -Value (Get-XcodeRootPath -Version $defaultXcode) | Out-Null