Skip to content

Commit ca66e82

Browse files
Try something
1 parent 0777397 commit ca66e82

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

.github/workflows/Action-Test.yml

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,32 @@ jobs:
7171
Write-Host "Resolved 'latest' → $requested"
7272
}
7373
74-
# Actual version installed by the action
75-
# Preview builds install the executable named 'pwsh-preview' on Windows,
76-
# so query that binary
77-
if ('${{ matrix.version }}'.Trim().ToLower() -eq 'preview' -and $IsWindows) {
78-
$installed = (pwsh-preview -NoLogo -NoProfile -Command '$PSVersionTable.PSVersion.ToString()')
74+
# Parse the major version from the requested version string
75+
$majorVersion = $requested -replace '-.*$', '' | ForEach-Object { ($_ -split '\.')[0] }
76+
Write-Host "Detected major version: $majorVersion"
77+
78+
# Determine the installation directory based on preview vs stable
79+
$isPreview = '${{ matrix.version }}'.Trim().ToLower() -eq 'preview' -or $requested -match '-preview\.'
80+
if ($isPreview) {
81+
$installDir = "$majorVersion-preview"
7982
} else {
80-
$installed = ($PSVersionTable.PSVersion).ToString()
83+
$installDir = "$majorVersion"
8184
}
85+
86+
$pwshPath = "$env:ProgramFiles\PowerShell\$installDir\pwsh.exe"
87+
Write-Host "Expected pwsh location: $pwshPath"
88+
89+
# Verify the file exists
90+
if (-not (Test-Path $pwshPath)) {
91+
Write-Host "ERROR: PowerShell executable not found at expected path: $pwshPath"
92+
Write-Host "`nSearching for all pwsh.exe installations..."
93+
Get-ChildItem "$env:ProgramFiles\PowerShell" -Recurse -Filter "pwsh.exe" -ErrorAction SilentlyContinue |
94+
ForEach-Object { Write-Host " Found: $($_.FullName)" }
95+
throw "PowerShell executable not found at: $pwshPath"
96+
}
97+
98+
# Get the version from the installed executable
99+
$installed = (& $pwshPath -NoLogo -NoProfile -Command '$PSVersionTable.PSVersion.ToString()')
82100
Write-Host "Installed PowerShell version: $installed"
83101
Write-Host "Expected PowerShell version: $requested"
84102

0 commit comments

Comments
 (0)