-
Notifications
You must be signed in to change notification settings - Fork 102
Add PSContentPath Standard Platform Paths #1912
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
base: master
Are you sure you want to change the base?
Conversation
|
Added support for Linux and MacOS pathway as well |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Opened PR to run CI tests here: #1913 |
|
Decided to use pwsh runspaces instead of reflection to call the PSContentPath API. |
|
Tests are looking good, currently 3 failing tests related to Lucene index issues (ie these are flakey tests due to a server side issue with the Gallery). In terms of this PR all tests are passing! |
|
All tests are passing now, PR looks good to me, just have one comment regarding whether to use default runspace created by the .Create() method or use current runspace. |
| if (psVersionObj != null) psVersion = new Version((int)psVersionObj.Major, (int)psVersionObj.Minor); | ||
| } | ||
| catch { | ||
| // Fallback if dynamic access fails |
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.
do we need to write a verbose message or warning?
| } | ||
|
|
||
| allUsersDir = System.IO.Path.Combine("/usr", "local", "share", "powershell"); | ||
| allUsersDir = Path.Combine("/usr", "local", "share", "powershell"); |
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.
| allUsersDir = Path.Combine("/usr", "local", "share", "powershell"); | |
| allUsersDir = Path.Combine("/", "usr", "local", "share", "powershell"); |
|
@jshigetomi we reviewed your PR, @anamnavi has a couple comments/suggestions. Everything looks good otherwise. Because we can't test these changes until 7.7 is released we're going to hold off on merging until then. |
PR Summary
This pull request introduces support for the PowerShell "PSContentPath" experimental feature, allowing users to customize the location of user content (such as modules and scripts) via an environment variable or configuration file. The code now prefers these new paths when the feature is enabled, improving flexibility and future compatibility.
Support for PSContentPath experimental feature:
powershell.config.json).PSUserContentPathin the environment variable or configuration file, using it as the base path for user content if it exists. If not set, it defaults toLocalApplicationData\PowerShell.MyDocuments\PowerShellfolder for user content.Refactoring and path resolution:
GetPathsFromEnvVarAndScopeto use the newpsUserContentPathvariable instead of the legacy documents path, ensuring the correct directory is used based on feature detection.Utility methods:
IsExperimentalFeatureEnabled(to check for enabled features in the config) andGetPSUserContentPath(to retrieve the custom user content path from environment or config).PR Context
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.