microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
23.03k stars 6.35k forks source link

powershell integration not automatically loaded in Powershell 5.1 #10619

Open linquize opened 4 years ago

linquize commented 4 years ago

Use Windows built-in powershell 5.1

Assume vcpkg is in C:\vcpkg

cd C:\vcpkg
.\vcpkg integrate powershell

Adding the following line to C:\Users\user\Documents\PowerShell\Microsoft.PowerShell_profile.ps1:
    Import-Module 'C:\vcpkg\scripts\posh-vcpkg'

Successfully added posh-vcpkg to your PowerShell profile. Please start a new Powershell window for the changes to take effect.

Start a new powershell 5.1

.\vcpkg install libf<press tab>

Autocomplete not working on a new powershell session. So I manually type

Import-Module 'C:\vcpkg\scripts\posh-vcpkg'

Now enter vcpkg command again

.\vcpkg install libf<press tab>

Autocomplete is working after manual input Import-Module

But if I start a new powershell-core 6.0 (in downloads\tools),

.\vcpkg install libf<press tab>

Autocomplete is working immediately on new session.

L-Sun commented 3 years ago

According to https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7.1, the correct path of profile is the output of $PROFILE from your powershell.