@@ -1371,6 +1371,7 @@ function New-UnixPackage {
13711371 AppsFolder = $AppsFolder
13721372 HostArchitecture = $HostArchitecture
13731373 CurrentLocation = $CurrentLocation
1374+ LTS = $LTS
13741375 }
13751376
13761377 try {
@@ -1515,7 +1516,12 @@ function New-MacOsDistributionPackage
15151516
15161517 # Get package ID if not provided
15171518 if (-not $PackageIdentifier ) {
1518- $PackageIdentifier = Get-MacOSPackageId - IsPreview:$IsPreview.IsPresent
1519+ if ($IsPreview.IsPresent ) {
1520+ $PackageIdentifier = ' com.microsoft.powershell-preview'
1521+ }
1522+ else {
1523+ $PackageIdentifier = ' com.microsoft.powershell'
1524+ }
15191525 }
15201526
15211527 # Minimum OS version
@@ -1984,7 +1990,9 @@ function New-MacOSPackage
19841990 [Parameter (Mandatory )]
19851991 [string ]$HostArchitecture ,
19861992
1987- [string ]$CurrentLocation = (Get-Location )
1993+ [string ]$CurrentLocation = (Get-Location ),
1994+
1995+ [switch ]$LTS
19881996 )
19891997
19901998 Write-Log " Creating macOS package using pkgbuild and productbuild..."
@@ -2059,8 +2067,10 @@ function New-MacOSPackage
20592067 Copy-Item - Path " $AppsFolder /*" - Destination $appsInPkg - Recurse - Force
20602068 }
20612069
2062- # Build the component package using pkgbuild
2063- $pkgIdentifier = Get-MacOSPackageId - IsPreview:($Name -like ' *-preview' )
2070+ # Get package identifier info based on version and LTS flag
2071+ $packageInfo = Get-MacOSPackageIdentifierInfo - Version $Version - LTS:$LTS
2072+ $IsPreview = $packageInfo.IsPreview
2073+ $pkgIdentifier = $packageInfo.PackageIdentifier
20642074
20652075 if ($PSCmdlet.ShouldProcess (" Build component package with pkgbuild" )) {
20662076 Write-Log " Running pkgbuild to create component package..."
@@ -2085,7 +2095,7 @@ function New-MacOSPackage
20852095 - OutputDirectory $CurrentLocation `
20862096 - HostArchitecture $HostArchitecture `
20872097 - PackageIdentifier $pkgIdentifier `
2088- - IsPreview:( $Name -like ' *-preview ' )
2098+ - IsPreview:$IsPreview
20892099
20902100 return $distributionPackage
20912101 }
@@ -2292,20 +2302,44 @@ function New-ManGzip
22922302 }
22932303}
22942304
2295- # Returns the macOS Package Identifier
2296- function Get-MacOSPackageId
2305+ <#
2306+ . SYNOPSIS
2307+ Determines the package identifier and preview status for macOS packages.
2308+ . DESCRIPTION
2309+ This function determines if a package is a preview build based on the version string
2310+ and LTS flag, then returns the appropriate package identifier.
2311+ . PARAMETER Version
2312+ The version string (e.g., "7.6.0-preview.6" or "7.6.0")
2313+ . PARAMETER LTS
2314+ Whether this is an LTS build
2315+ . OUTPUTS
2316+ Hashtable with IsPreview (boolean) and PackageIdentifier (string) properties
2317+ . EXAMPLE
2318+ Get-MacOSPackageIdentifierInfo -Version "7.6.0-preview.6" -LTS:$false
2319+ Returns @{ IsPreview = $true; PackageIdentifier = "com.microsoft.powershell-preview" }
2320+ #>
2321+ function Get-MacOSPackageIdentifierInfo
22972322{
22982323 param (
2299- [switch ]
2300- $IsPreview
2324+ [Parameter (Mandatory )]
2325+ [string ]$Version ,
2326+
2327+ [switch ]$LTS
23012328 )
2302- if ($IsPreview.IsPresent )
2303- {
2304- return ' com.microsoft.powershell-preview'
2329+
2330+ $IsPreview = Test-IsPreview - Version $Version - IsLTS:$LTS
2331+
2332+ # Determine package identifier based on preview status
2333+ if ($IsPreview ) {
2334+ $PackageIdentifier = ' com.microsoft.powershell-preview'
23052335 }
2306- else
2307- {
2308- return ' com.microsoft.powershell'
2336+ else {
2337+ $PackageIdentifier = ' com.microsoft.powershell'
2338+ }
2339+
2340+ return @ {
2341+ IsPreview = $IsPreview
2342+ PackageIdentifier = $PackageIdentifier
23092343 }
23102344}
23112345
@@ -2319,8 +2353,9 @@ function New-MacOSLauncher
23192353 [switch ]$LTS
23202354 )
23212355
2322- $IsPreview = Test-IsPreview - Version $Version - IsLTS:$LTS
2323- $packageId = Get-MacOSPackageId - IsPreview:$IsPreview
2356+ $packageInfo = Get-MacOSPackageIdentifierInfo - Version $Version - LTS:$LTS
2357+ $IsPreview = $packageInfo.IsPreview
2358+ $packageId = $packageInfo.PackageIdentifier
23242359
23252360 # Define folder for launcher application.
23262361 $suffix = if ($IsPreview ) { " -preview" } elseif ($LTS ) { " -lts" }
0 commit comments