PowerShell / vscode-powershell

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

Loading of third-part modules #134

Closed tibmeister closed 8 years ago

tibmeister commented 8 years ago

Maybe not a bug but just not obvious but I work a lot with VMware's PowerCLI and as such I have to import a lot of modules and snappins but this doesn't seem to happen in VS Code. In using the ISE or PowerGUI when they started my Powershell Profile would be loaded which takes care of all of this but in VS Code with this extension that doesn't seem to be the case so I don't have Intellisense for the PowerCLI or custom commandlets.

rkeithhill commented 8 years ago

Profile script loading support will be coming in the next drop of the extension. It will be turned off by default initially but you will be able to turn it on via user preferences. This will support the editor host/session but IIRC not the debug host i.e. you will need to make sure your script loads all the modules it needs for execution.

tibmeister commented 8 years ago

So is there a way to load the modules to gain Intellisense, if not now then in a future release?

rkeithhill commented 8 years ago

Yes but not in 0.5.0. The next release will process your profile scripts (including a host-specific script for VSCode) if you enable the user preference setting. This will enable completion lists for those modules you load in your profile scripts.

For more info on this see https://github.com/PowerShell/PowerShellEditorServices/issues/111

tibmeister commented 8 years ago

I looked through the Issue 111 but not seeing on how to enable this. I'm sure I'm just missing it.

rkeithhill commented 8 years ago

The setting in the next update (> 0.5.0) will be powershell.enableProfileLoading. You'll override that and set it to true.

tibmeister commented 8 years ago

Ahh, got it. I will clone that down and check it out.

daviwil commented 8 years ago

Hey @tibmeister, did the new profile support solve your problem with loading third-party modules? Let me know!

tibmeister commented 8 years ago

Yes, after creating the Microsoft.VSCode_profile.ps1 file and copying the contents of the standard profile file into this then things began working as expected.

I didn't see this in the documentation anywhere and took a shot in the dark based on the way the ISE works and PowerGUI.

Definitely wondering how this would work on other OS's once we can run PowerShell there, Linux comes to mind personally.

daviwil commented 8 years ago

Thanks for confirming that Jody! I'll go ahead and close this issue.

You can run PowerShell and the PowerShell VS Code extension on Linux and OS X right now:

https://github.com/PowerShell/PowerShell https://github.com/PowerShell/PowerShell/blob/master/docs/learning-powershell/using-vscode.md

The profile support will work the same way as it does on Windows, just with OS-specific profile paths. If you open PowerShell on Linux you can use your favorite editor to edit the file in the path that's stored in the $profile variable.