Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
[release/v7.5] Fix macOS preview package identifier detection to use version string #26835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT License. | ||
|
|
||
| Describe "Packaging Module Functions" { | ||
| BeforeAll { | ||
| Import-Module $PSScriptRoot/../../build.psm1 -Force | ||
| Import-Module $PSScriptRoot/../../tools/packaging/packaging.psm1 -Force | ||
| } | ||
|
|
||
| Context "Test-IsPreview function" { | ||
| It "Should return True for preview versions" { | ||
| Test-IsPreview -Version "7.6.0-preview.6" | Should -Be $true | ||
| Test-IsPreview -Version "7.5.0-rc.1" | Should -Be $true | ||
| } | ||
|
|
||
| It "Should return False for stable versions" { | ||
| Test-IsPreview -Version "7.6.0" | Should -Be $false | ||
| Test-IsPreview -Version "7.5.0" | Should -Be $false | ||
| } | ||
|
|
||
| It "Should return False for LTS builds regardless of version string" { | ||
| Test-IsPreview -Version "7.6.0-preview.6" -IsLTS | Should -Be $false | ||
| Test-IsPreview -Version "7.5.0" -IsLTS | Should -Be $false | ||
| } | ||
| } | ||
|
|
||
| Context "Get-MacOSPackageIdentifierInfo function (New-MacOSPackage logic)" { | ||
| It "Should detect preview builds and return preview identifier" { | ||
| $result = Get-MacOSPackageIdentifierInfo -Version "7.6.0-preview.6" -LTS:$false | ||
|
|
||
| $result.IsPreview | Should -Be $true | ||
| $result.PackageIdentifier | Should -Be "com.microsoft.powershell-preview" | ||
| } | ||
|
|
||
| It "Should detect stable builds and return stable identifier" { | ||
| $result = Get-MacOSPackageIdentifierInfo -Version "7.6.0" -LTS:$false | ||
|
|
||
| $result.IsPreview | Should -Be $false | ||
| $result.PackageIdentifier | Should -Be "com.microsoft.powershell" | ||
| } | ||
|
|
||
| It "Should treat LTS builds as stable even with preview version string" { | ||
| $result = Get-MacOSPackageIdentifierInfo -Version "7.4.0-preview.1" -LTS:$true | ||
|
|
||
| $result.IsPreview | Should -Be $false | ||
| $result.PackageIdentifier | Should -Be "com.microsoft.powershell" | ||
| } | ||
|
|
||
| It "Should NOT use package name for preview detection (bug fix verification)" { | ||
| # This test verifies the fix for issue #26673 | ||
| # The bug was using ($Name -like '*-preview') which always returned false | ||
| # because preview builds use Name="powershell" not "powershell-preview" | ||
|
|
||
| $Version = "7.6.0-preview.6" | ||
| $Name = "powershell" # Preview builds use "powershell" not "powershell-preview" | ||
|
|
||
| # The INCORRECT logic (the bug): $Name -like '*-preview' | ||
| $incorrectCheck = $Name -like '*-preview' | ||
| $incorrectCheck | Should -Be $false -Because "Package name is 'powershell' not 'powershell-preview'" | ||
|
|
||
| # The CORRECT logic (the fix): uses version string | ||
| $result = Get-MacOSPackageIdentifierInfo -Version $Version -LTS:$false | ||
| $result.IsPreview | Should -Be $true -Because "Version string correctly identifies preview" | ||
| $result.PackageIdentifier | Should -Be "com.microsoft.powershell-preview" | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1359,6 +1359,7 @@ function New-UnixPackage { | |||||||||||||||||
| AppsFolder = $AppsFolder | ||||||||||||||||||
| HostArchitecture = $HostArchitecture | ||||||||||||||||||
| CurrentLocation = $CurrentLocation | ||||||||||||||||||
| LTS = $LTS | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| try { | ||||||||||||||||||
|
|
@@ -1503,7 +1504,12 @@ function New-MacOsDistributionPackage | |||||||||||||||||
|
|
||||||||||||||||||
| # Get package ID if not provided | ||||||||||||||||||
| if (-not $PackageIdentifier) { | ||||||||||||||||||
| $PackageIdentifier = Get-MacOSPackageId -IsPreview:$IsPreview.IsPresent | ||||||||||||||||||
| if ($IsPreview.IsPresent) { | ||||||||||||||||||
| $PackageIdentifier = 'com.microsoft.powershell-preview' | ||||||||||||||||||
| } | ||||||||||||||||||
| else { | ||||||||||||||||||
| $PackageIdentifier = 'com.microsoft.powershell' | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+1507
to
+1512
|
||||||||||||||||||
| if ($IsPreview.IsPresent) { | |
| $PackageIdentifier = 'com.microsoft.powershell-preview' | |
| } | |
| else { | |
| $PackageIdentifier = 'com.microsoft.powershell' | |
| } | |
| $macOSPackageInfo = Get-MacOSPackageIdentifierInfo -IsPreview:$IsPreview | |
| $PackageIdentifier = $macOSPackageInfo.PackageIdentifier |
Copilot
AI
Feb 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description says preview macOS packages will install to /usr/local/microsoft/powershell/7-preview/, but this change only fixes the package identifier determination. The install location is determined earlier by New-UnixPackage via $Suffix/$Destination (which depends on $IsPreview), and New-UnixPackage does not currently compute $IsPreview from the version string (so it stays $null/false and yields the stable 7/ suffix). To fully fix issue #26673, compute $IsPreview in New-UnixPackage using Test-IsPreview -Version $Version -IsLTS:$LTS and use that value consistently for $Suffix/$Destination (and for macOS launcher generation as needed).

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new tests validate
Test-IsPreviewandGet-MacOSPackageIdentifierInfo, but they don't cover the behavior that actually drives the reported customer impact: the macOS package install path suffix (7-previewvs7) derived inNew-UnixPackage. Adding a focused unit test that asserts the computedDestination/suffix for preview vs stable vs LTS would help prevent regressions (ideally by factoring the suffix/path computation into a small helper that can be tested without building a real pkg).