http://blogs.msdn.com/b/powershell/archive/2010/06/21/powershell-integration-into-visual-studio.aspx details a PSH Visual Studio Extension that allows VS users to edit PowerShell scripts in Visual Studio. The bits are located here: http://powerguivsx.codeplex.com/.
It’s actually not that good – it requires a downrev version of PowerGUI Script Editor (specifically 3.2) and basically wraps the VS IDE around the Script Editor. I don’t see a way to create a solution (group of multiple related files). Also,the editor behaviours are still controlled by PowerGUI Script Editor, so there isn’t an innate hotkey for collapsing code blocks.
And, it doesn’t work with VisualStudio 2012.
The bugbear is the extension.vsixmanifest file, which caps out the support VS version to 11.0. The codeplex.com page does have an alpha version of 1.6.1 that is listed to work with VS 2012, but it says alpha, so I’m a little nervous.
A well-documented hack-around is to rename the PowerGUIVsx.vsix file to a .ZIP, extract and edit the extension.vsixmanifest file, overwrite it in the .ZIP, and rename the .ZIP back to PowerGUIVsx.vsix. For some reason or another, I decided it was a good idea to automate it, in part to learn about manipulating .ZIP files with PowerShell.
I see now why there are so many web pages that recommend either calling 7z.exe or other ZIP libraries. COMObject ZIP manipulation is half-baked, painful, and generally harmful to grey matter. Specifically, when running this function, you’ll see this pop up:
That’s because the PSH COMObject doesn’t respect the vOptions documented on MSDN to forcibly overwrite. Instead, it displays the “do you want to overwrite” dialog, and then immediately executes the next line, so your response doesn’t matter.
Deleting a file from the ZIP COMObject at least interrupts the script, but I can’t find a way to forcibly delete it. Thus, the dialog box.
Click ‘Yes’ to continue.