-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Enable Windows PowerShell PSModulePath by default on Windows #4132
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
Enable Windows PowerShell PSModulePath by default on Windows #4132
Conversation
…ell PSModulePath by default to encourage testing of using FullCLR modules
build.psm1
Outdated
| The currently installed .NET Command Line Tools is not the required version. | ||
| Installed version: $dotnetCLIIntalledVersion | ||
| Installed version: $dotnetCLIIntalledVersion |
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.
Typo in Installed.
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.
That wasn't part of this PR, but since I only see 3 hits, I'm leaning towards fixing it here instead of a new PR
| # If a Windows PowerShell module works or not, please provide feedback at https://github.com/PowerShell/PowerShell/issues/4062 | ||
|
|
||
| Write-Warning "Appended Windows PowerShell PSModulePath" | ||
| $env:psmodulepath += ";${env:userprofile}\Documents\WindowsPowerShell\Modules;${env:programfiles}\WindowsPowerShell\Modules;${env:windir}\system32\WindowsPowerShell\v1.0\Modules\" |
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.
This only gets the default, if the Windows PSModulePath is modified by installing Azure cmdlets or SQL, then they won't be available. We would need something like this:
$env:PSModulePath += (";" + (& ${env:windir}\system32\windowspowershell\v1.0\powershell.exe '$env:PSModulePath'))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.
Calling out to Windows PowerShell can incur a 150-250ms startup penalty. Since this change isn't intended to be the final solution and just helps to get customer feedback, I think we are ok with it not being 100% accurate. Advanced customers can update their PSModulePath as needed.
|
Although I intend for this to be temporary, I'll add a test case |
232f7f3 to
4f067eb
Compare
4f067eb to
1eb7b51
Compare
build.psm1
Outdated
| # copy PowerShell host profile if Windows | ||
| if ($IsWindows) | ||
| { | ||
| Copy-Item -Path "$PSScriptRoot/src/powershell-win-core/Microsoft.PowerShell_profile.ps1" -Destination $publishPath |
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.
-Force ? When rebuilding without cleaning.
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.
make sense, will add
|
|
||
| It "Default PowerShell profile appends Windows PowerShell PSModulePath only on Windows" { | ||
|
|
||
| $psmodulepath = & $powershell -c '$env:PSModulePath' |
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.
Like in this test case, would other tests now have the warning message and fail? Can you verify by running all tests?
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.
I thought I did, but hit a few more failures. Will fix.
|
Because this is a temporary change - can we have a temporary test that will fail at some fixed point in the future - even if it's a nightly failure, that would be fine. The point here - if we reach that point where the test starts failing, we need to take action, either implement this correctly (not via a profile script), remove it, or something else. |
1eb7b51 to
85b6401
Compare
|
@lzybkr rather than having a temporary test, I've changed this to not be a 'fix' but related so we'll keep the issue open and will revisit after we get some customer data |
…ell into windows-psmodulepath
|
@adityapatwardhan looks like I had some changes staged on a different computer that wasn't committed (Console Tests), can you take a quick look? |
adityapatwardhan
left a comment
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.
LGTM
|
@lzybkr can you merge so we can get this in for beta.4? |
|
@TravisEz13 can you merge this since @lzybkr is currently out of office? |
|
This change doesn't make sense on new Nano Server container. "WARNING: Appended Windows PowerShell PSModulePath" 3 of those 5 paths are unnecessary on new Nano Server. |
|
@alexandair you are correct, NanoServer-Insider doesn't have Windows PowerShell Core 5.1 anymore. Can you add a comment to #4056? The final resolution to this will likely be adding a config setting to the startup json file and checking if full windows. Thanks. |
|
@SteveL-MSFT Done. |
|
Is there a way to turn off the warning? It's fairly annoying and I can give feedback without it reminding me on every startup. |
|
@MathiasMagnus edit Microsoft.PowerShell_profile.ps1 in $PSHome and remove the Write-Warning line |
|
@SteveL-MSFT Thanks. :) As a sidenote: is it instructive to think that these are 1-to-1 mappings?
|
|
@MathiasMagnus yes |
Now that we have moved to .Net Std 2.0 compatible CoreClr 2.0 and added capability to search GAC for assemblies, we need to make it easier for users to use Windows PowerShell modules from PSCore6 to get feedback on compatibility.
This change is only for Windows and appends the Windows PowerShell PSModulePath on startup. Depending on the data/feedback we get, we can decide what to do (opt-in vs opt-out) as we get closer to a release candidate.
Out-Default tests has to be updated to suppress the Warning message by not loading the profile.
Related #4056
Based on the customer data, we can decide a more permanent solution.