@@ -1360,6 +1360,7 @@ function New-UnixPackage {
13601360 AppsFolder = $AppsFolder
13611361 HostArchitecture = $HostArchitecture
13621362 CurrentLocation = $CurrentLocation
1363+ LTS = $LTS
13631364 }
13641365
13651366 try {
@@ -1504,7 +1505,12 @@ function New-MacOsDistributionPackage
15041505
15051506 # Get package ID if not provided
15061507 if (-not $PackageIdentifier ) {
1507- $PackageIdentifier = Get-MacOSPackageId - IsPreview:$IsPreview.IsPresent
1508+ if ($IsPreview.IsPresent ) {
1509+ $PackageIdentifier = ' com.microsoft.powershell-preview'
1510+ }
1511+ else {
1512+ $PackageIdentifier = ' com.microsoft.powershell'
1513+ }
15081514 }
15091515
15101516 # Minimum OS version
@@ -1973,7 +1979,9 @@ function New-MacOSPackage
19731979 [Parameter (Mandatory )]
19741980 [string ]$HostArchitecture ,
19751981
1976- [string ]$CurrentLocation = (Get-Location )
1982+ [string ]$CurrentLocation = (Get-Location ),
1983+
1984+ [switch ]$LTS
19771985 )
19781986
19791987 Write-Log " Creating macOS package using pkgbuild and productbuild..."
@@ -2048,8 +2056,10 @@ function New-MacOSPackage
20482056 Copy-Item - Path " $AppsFolder /*" - Destination $appsInPkg - Recurse - Force
20492057 }
20502058
2051- # Build the component package using pkgbuild
2052- $pkgIdentifier = Get-MacOSPackageId - IsPreview:($Name -like ' *-preview' )
2059+ # Get package identifier info based on version and LTS flag
2060+ $packageInfo = Get-MacOSPackageIdentifierInfo - Version $Version - LTS:$LTS
2061+ $IsPreview = $packageInfo.IsPreview
2062+ $pkgIdentifier = $packageInfo.PackageIdentifier
20532063
20542064 if ($PSCmdlet.ShouldProcess (" Build component package with pkgbuild" )) {
20552065 Write-Log " Running pkgbuild to create component package..."
@@ -2074,7 +2084,7 @@ function New-MacOSPackage
20742084 - OutputDirectory $CurrentLocation `
20752085 - HostArchitecture $HostArchitecture `
20762086 - PackageIdentifier $pkgIdentifier `
2077- - IsPreview:( $Name -like ' *-preview ' )
2087+ - IsPreview:$IsPreview
20782088
20792089 return $distributionPackage
20802090 }
@@ -2261,20 +2271,44 @@ function New-ManGzip
22612271 }
22622272}
22632273
2264- # Returns the macOS Package Identifier
2265- function Get-MacOSPackageId
2274+ <#
2275+ . SYNOPSIS
2276+ Determines the package identifier and preview status for macOS packages.
2277+ . DESCRIPTION
2278+ This function determines if a package is a preview build based on the version string
2279+ and LTS flag, then returns the appropriate package identifier.
2280+ . PARAMETER Version
2281+ The version string (e.g., "7.6.0-preview.6" or "7.6.0")
2282+ . PARAMETER LTS
2283+ Whether this is an LTS build
2284+ . OUTPUTS
2285+ Hashtable with IsPreview (boolean) and PackageIdentifier (string) properties
2286+ . EXAMPLE
2287+ Get-MacOSPackageIdentifierInfo -Version "7.6.0-preview.6" -LTS:$false
2288+ Returns @{ IsPreview = $true; PackageIdentifier = "com.microsoft.powershell-preview" }
2289+ #>
2290+ function Get-MacOSPackageIdentifierInfo
22662291{
22672292 param (
2268- [switch ]
2269- $IsPreview
2293+ [Parameter (Mandatory )]
2294+ [string ]$Version ,
2295+
2296+ [switch ]$LTS
22702297 )
2271- if ($IsPreview.IsPresent )
2272- {
2273- return ' com.microsoft.powershell-preview'
2298+
2299+ $IsPreview = Test-IsPreview - Version $Version - IsLTS:$LTS
2300+
2301+ # Determine package identifier based on preview status
2302+ if ($IsPreview ) {
2303+ $PackageIdentifier = ' com.microsoft.powershell-preview'
22742304 }
2275- else
2276- {
2277- return ' com.microsoft.powershell'
2305+ else {
2306+ $PackageIdentifier = ' com.microsoft.powershell'
2307+ }
2308+
2309+ return @ {
2310+ IsPreview = $IsPreview
2311+ PackageIdentifier = $PackageIdentifier
22782312 }
22792313}
22802314
@@ -2288,8 +2322,9 @@ function New-MacOSLauncher
22882322 [switch ]$LTS
22892323 )
22902324
2291- $IsPreview = Test-IsPreview - Version $Version - IsLTS:$LTS
2292- $packageId = Get-MacOSPackageId - IsPreview:$IsPreview
2325+ $packageInfo = Get-MacOSPackageIdentifierInfo - Version $Version - LTS:$LTS
2326+ $IsPreview = $packageInfo.IsPreview
2327+ $packageId = $packageInfo.PackageIdentifier
22932328
22942329 # Define folder for launcher application.
22952330 $suffix = if ($IsPreview ) { " -preview" } elseif ($LTS ) { " -lts" }
0 commit comments