Repository navigation
Auto-detect Microsoft Store PowerShell 7 and add custom interpreter path setting - #17
Open
cameronmid-lang wants to merge 1 commit into
Open
cameronmid-lang wants to merge 1 commit into
cameronmid-lang wants to merge 1 commit into
Conversation
…ng. Additionally, implement script runner, compatibility validation, and settings manager with tests and documentation
Owner
|
Just FYI, I am still working on testing these changes and making a few modifications. The loading of a profile can break certain functionality if the profile had things in it that would echo output for example. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves PowerShell 7 discovery by auto-detecting Microsoft Store package installations of
pwsh.exe, adds a configurable custom interpreter path setting, supports direct executable paths in[ScriptHost(...)], and introduces an optional toggle to load PowerShell$PROFILE.Context & Motivation
When PowerShell 7 is installed from the Microsoft Store (or via
winget), its executable resides inside a package subdirectory:%LOCALAPPDATA%\Microsoft\WindowsApps\Microsoft.PowerShell_8wekyb3d8bbwe\pwsh.exePreviously,
ScriptRunner.PwshInstallDirs()only checked the root of%LOCALAPPDATA%\Microsoft\WindowsAppswithout enumeratingMicrosoft.PowerShell*package subdirectories. Whenpwsh.exewas not found on PATH or in standardProgram Files, PaletteShell silently fell back to Windows PowerShell 5.1 (powershell.exe).In many managed or enterprise environments, Windows PowerShell 5.1 has execution restrictions enforced by policy, whereas PowerShell 7 runs without issue. This caused scripts to fail with authorization errors for users who installed PowerShell 7 from the Store.
Changes
Auto-Detect Store PowerShell Packages:
ScriptRunner.PwshInstallDirs()to enumerateMicrosoft.PowerShell*package subdirectories under%LOCALAPPDATA%\Microsoft\WindowsApps.Custom PowerShell Path Setting:
customPowerShellPath(TextSetting) inPaletteShellSettingsManager.csso users can explicitly configure an interpreter path in settings.ScriptRunner.FindPwsh()checks this custom path first before scanning standard locations.Direct Executable Path Support in
[ScriptHost(...)]:ScriptRunner.ParseHost()andScriptRunner.ResolveShell()to accept and validate direct file paths to executables (e.g.[ScriptHost('C:\path\to\pwsh.exe')]).ScriptCompatibilityValidator.csto ensure valid custom paths pass compatibility checks.Optional Profile Loading:
loadPowerShellProfile(ToggleSetting) inPaletteShellSettingsManager.cs. When enabled,-NoProfileis omitted fromBuildProcessStartInfo, allowing scripts to load the user's PowerShell$PROFILE.Tests & Documentation:
ScriptRunnerTests.csfor host parsing, resolution, andWindowsAppsdirectory discovery.PaletteShellScripts.AGENTS.md,PaletteShellScripts.Reference.md, andextension-behavior-reference.md.Validation
PwshInstallDirs()discovers the Microsoft Store package folder.ScriptRunnerTests.csfor standard and custom executable host parsing.