Skip to content

Conversation

@SteveL-MSFT
Copy link
Member

@SteveL-MSFT SteveL-MSFT commented Jun 28, 2017

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.

…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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in Installed.

Copy link
Member Author

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\"
Copy link
Member

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'))

Copy link
Member Author

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.

@SteveL-MSFT
Copy link
Member Author

Although I intend for this to be temporary, I'll add a test case

@SteveL-MSFT SteveL-MSFT force-pushed the windows-psmodulepath branch from 232f7f3 to 4f067eb Compare June 28, 2017 20:41
@SteveL-MSFT SteveL-MSFT force-pushed the windows-psmodulepath branch from 4f067eb to 1eb7b51 Compare June 28, 2017 21:24
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
Copy link
Member

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.

Copy link
Member Author

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'
Copy link
Member

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?

Copy link
Member Author

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.

@lzybkr
Copy link
Contributor

lzybkr commented Jun 29, 2017

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.

@SteveL-MSFT SteveL-MSFT force-pushed the windows-psmodulepath branch from 1eb7b51 to 85b6401 Compare June 30, 2017 17:37
@SteveL-MSFT
Copy link
Member Author

@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

@SteveL-MSFT
Copy link
Member Author

@adityapatwardhan looks like I had some changes staged on a different computer that wasn't committed (Console Tests), can you take a quick look?

Copy link
Member

@adityapatwardhan adityapatwardhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SteveL-MSFT
Copy link
Member Author

@lzybkr can you merge so we can get this in for beta.4?

@SteveL-MSFT SteveL-MSFT assigned TravisEz13 and unassigned lzybkr Jul 6, 2017
@SteveL-MSFT
Copy link
Member Author

@TravisEz13 can you merge this since @lzybkr is currently out of office?

@daxian-dbw daxian-dbw merged commit 7bce165 into PowerShell:master Jul 7, 2017
@alexandair
Copy link
Contributor

This change doesn't make sense on new Nano Server container.
This is what you see when you start microsoft/nanoserver-insider-powershell:

"WARNING: Appended Windows PowerShell PSModulePath"

PS C:\> $env:psmodulepath -split ';'
PowerShell\Modules
c:\program files\powershell\Modules
C:\Users\ContainerUser\Documents\WindowsPowerShell\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\

3 of those 5 paths are unnecessary on new Nano Server.

@SteveL-MSFT
Copy link
Member Author

@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 SteveL-MSFT deleted the windows-psmodulepath branch July 17, 2017 15:52
@alexandair
Copy link
Contributor

@SteveL-MSFT Done.

@MathiasMagnus
Copy link
Contributor

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.

@SteveL-MSFT
Copy link
Member Author

@MathiasMagnus edit Microsoft.PowerShell_profile.ps1 in $PSHome and remove the Write-Warning line

@MathiasMagnus
Copy link
Contributor

@SteveL-MSFT Thanks. :)

As a sidenote: is it instructive to think that these are 1-to-1 mappings?

Powershell Bash
$PSHOME\Microsoft.PowerShell_profile.ps1 /etc/profile
$PROFILE ~/.profile

@SteveL-MSFT
Copy link
Member Author

@MathiasMagnus yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants