PowerShell / vscode-powershell

Provides PowerShell language and debugging support for Visual Studio Code
https://marketplace.visualstudio.com/items/ms-vscode.PowerShell
MIT License
1.69k stars 487 forks source link

PowerShell profile not loaded in temporary PowerShell Integrated Console when `powershell.debugging.createTemporaryIntegratedConsole` is set to true #1468

Open ohadschn opened 6 years ago

ohadschn commented 6 years ago

System Details

PS C:\Users\ohads\Documents\PowerShell> code -v
1.25.1
1dfc5e557209371715f655691b1235b6b26a06be
x64
PS C:\Users\ohads\Documents\PowerShell> $pseditor.EditorServicesVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
1      8      2      0

PS C:\Users\ohads\Documents\PowerShell> code --list-extensions --show-versions
bradygaster.azuretoolsforvscode@1.3.0
codezombiech.gitignore@0.5.0
dbaeumer.vscode-eslint@1.4.12
DotJoshJohnson.xml@2.3.1
DSKWRK.vscode-generate-getter-setter@0.5.0
eg2.tslint@1.0.34
ionutvmi.path-autocomplete@1.12.0
johnpapa.azure-functions-tools@0.3.1
mohsen1.prettify-json@0.0.3
ms-vscode.csharp@1.15.2
ms-vscode.PowerShell@1.8.2
robrodi.language-bond@0.0.1
msazurermtools.azurerm-vscode-tools@0.4.2
pmneo.tsimporter@1.2.14
rbbit.typescript-hero@2.3.2
streetsidesoftware.code-spell-checker@1.6.10
yzane.markdown-pdf@1.2.0
PS C:\Users\ohads\Documents\PowerShell> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.17134.165
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17134.165
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

The PowerShell terminal and the PowerShell Integrated Console both load PowerShell profiles. However, when setting powershell.debugging.createTemporaryIntegratedConsole to true, profiles are not loaded. Looking at process explorer, I believe powershell.exe is being executed with -NoProfile. This is undocumented, inconsistent, and IMO undesired.

SeeminglyScience commented 6 years ago

The integrated console is always started with -NoProfile because our custom host does the profile processing.

That profile processing step is probably skipped for temporary consoles though. Not sure if that was a design decision or something that fell threw the cracks. Either way, profile loading for temporary consoles should definitely be an option (and probably on by default)

rkeithhill commented 6 years ago

Early on the extension didn't have a custom host and debug input/output happened via the Debug Console. I think we suppressed profiles back then. The addition of the "temporary console" was to attempt to bring back something like that debug experience where you started with a fresh & clean session every time. Debugging with persistent state can be very handy but also somewhat dangerous. You can fool yourself into thinking your script works when in fact, in a clean session it won't work.

While I can see having a setting to enable profile processing in the temp console, I personally don't think it should be the default. Relying (intentionally or unintentionally) on local state created by your profile, is not a recipe for success when that script is moved to another machine with a different profile configuration.

webtroter commented 3 years ago

Hi,

I use temporary session because I write powershell Classes. But my prompt is often too long and I'd like to set it in the profile.

I sadly don't have code to contribute. Maybe if I could pass the prompt somehow in the vscode launch.json that would be great.

Thanks a lot!