@@ -1359,6 +1359,7 @@ function New-UnixPackage {
13591359 AppsFolder = $AppsFolder
13601360 HostArchitecture = $HostArchitecture
13611361 CurrentLocation = $CurrentLocation
1362+ LTS = $LTS
13621363 }
13631364
13641365 try {
@@ -1503,7 +1504,12 @@ function New-MacOsDistributionPackage
15031504
15041505 # Get package ID if not provided
15051506 if (-not $PackageIdentifier ) {
1506- $PackageIdentifier = Get-MacOSPackageId - IsPreview:$IsPreview.IsPresent
1507+ if ($IsPreview.IsPresent ) {
1508+ $PackageIdentifier = ' com.microsoft.powershell-preview'
1509+ }
1510+ else {
1511+ $PackageIdentifier = ' com.microsoft.powershell'
1512+ }
15071513 }
15081514
15091515 # Minimum OS version
@@ -1972,7 +1978,9 @@ function New-MacOSPackage
19721978 [Parameter (Mandatory )]
19731979 [string ]$HostArchitecture ,
19741980
1975- [string ]$CurrentLocation = (Get-Location )
1981+ [string ]$CurrentLocation = (Get-Location ),
1982+
1983+ [switch ]$LTS
19761984 )
19771985
19781986 Write-Log " Creating macOS package using pkgbuild and productbuild..."
@@ -2047,8 +2055,10 @@ function New-MacOSPackage
20472055 Copy-Item - Path " $AppsFolder /*" - Destination $appsInPkg - Recurse - Force
20482056 }
20492057
2050- # Build the component package using pkgbuild
2051- $pkgIdentifier = Get-MacOSPackageId - IsPreview:($Name -like ' *-preview' )
2058+ # Get package identifier info based on version and LTS flag
2059+ $packageInfo = Get-MacOSPackageIdentifierInfo - Version $Version - LTS:$LTS
2060+ $IsPreview = $packageInfo.IsPreview
2061+ $pkgIdentifier = $packageInfo.PackageIdentifier
20522062
20532063 if ($PSCmdlet.ShouldProcess (" Build component package with pkgbuild" )) {
20542064 Write-Log " Running pkgbuild to create component package..."
@@ -2073,7 +2083,7 @@ function New-MacOSPackage
20732083 - OutputDirectory $CurrentLocation `
20742084 - HostArchitecture $HostArchitecture `
20752085 - PackageIdentifier $pkgIdentifier `
2076- - IsPreview:( $Name -like ' *-preview ' )
2086+ - IsPreview:$IsPreview
20772087
20782088 return $distributionPackage
20792089 }
@@ -2275,20 +2285,44 @@ function New-ManGzip
22752285 }
22762286}
22772287
2278- # Returns the macOS Package Identifier
2279- function Get-MacOSPackageId
2288+ <#
2289+ . SYNOPSIS
2290+ Determines the package identifier and preview status for macOS packages.
2291+ . DESCRIPTION
2292+ This function determines if a package is a preview build based on the version string
2293+ and LTS flag, then returns the appropriate package identifier.
2294+ . PARAMETER Version
2295+ The version string (e.g., "7.6.0-preview.6" or "7.6.0")
2296+ . PARAMETER LTS
2297+ Whether this is an LTS build
2298+ . OUTPUTS
2299+ Hashtable with IsPreview (boolean) and PackageIdentifier (string) properties
2300+ . EXAMPLE
2301+ Get-MacOSPackageIdentifierInfo -Version "7.6.0-preview.6" -LTS:$false
2302+ Returns @{ IsPreview = $true; PackageIdentifier = "com.microsoft.powershell-preview" }
2303+ #>
2304+ function Get-MacOSPackageIdentifierInfo
22802305{
22812306 param (
2282- [switch ]
2283- $IsPreview
2307+ [Parameter (Mandatory )]
2308+ [string ]$Version ,
2309+
2310+ [switch ]$LTS
22842311 )
2285- if ($IsPreview.IsPresent )
2286- {
2287- return ' com.microsoft.powershell-preview'
2312+
2313+ $IsPreview = Test-IsPreview - Version $Version - IsLTS:$LTS
2314+
2315+ # Determine package identifier based on preview status
2316+ if ($IsPreview ) {
2317+ $PackageIdentifier = ' com.microsoft.powershell-preview'
22882318 }
2289- else
2290- {
2291- return ' com.microsoft.powershell'
2319+ else {
2320+ $PackageIdentifier = ' com.microsoft.powershell'
2321+ }
2322+
2323+ return @ {
2324+ IsPreview = $IsPreview
2325+ PackageIdentifier = $PackageIdentifier
22922326 }
22932327}
22942328
@@ -2302,8 +2336,9 @@ function New-MacOSLauncher
23022336 [switch ]$LTS
23032337 )
23042338
2305- $IsPreview = Test-IsPreview - Version $Version - IsLTS:$LTS
2306- $packageId = Get-MacOSPackageId - IsPreview:$IsPreview
2339+ $packageInfo = Get-MacOSPackageIdentifierInfo - Version $Version - LTS:$LTS
2340+ $IsPreview = $packageInfo.IsPreview
2341+ $packageId = $packageInfo.PackageIdentifier
23072342
23082343 # Define folder for launcher application.
23092344 $suffix = if ($IsPreview ) { " -preview" } elseif ($LTS ) { " -lts" }
0 commit comments