PowerShell Tools for Visual Studio

on Friday, May 2, 2014

Last week I tried out PowerShell Tools for Visual Studio by Adam Driscoll. I liked the features a lot, but had some difficulty getting used to not having the instant feedback from a command window.

Goods News on the Command Window. It looks like Mr. Driscoll is implementing that feature right now. He added a REPL window to the GitHub repository just a few days ago. (I was also surprised to see that the code is Copyright by Microsoft. I thought Mr. Driscoll worked for DELL/PowerGUI?)

This week I had the opportunity to try PowerShell with TFS 2013 source control. This brought me right back to Visual Studio to handle the check-ins and check-outs. So I spent a lot of this week with PowerShell in VS2013.

Since I normally work in VS2013, continuing to use it as my primary IDE felt very natural. Some features that struck me were:

  • PowerShell projects in the Solution Explorer
    • Having all your files under one easy to view place, where you can quickly pull them up to edit is very useful.
  • Having keyboard shortcuts that I’m used to
    • The biggest one of these was multi-line comment and uncomment. I am very used to Ctrl+K,Ctrl+C to comment and it’s twin. And, when I was in the ISE I found myself constantly trying to use that command.
  • Built In Source Control Integration
  • IntelliSense can be Very Unresponsive
    • It can be a 2~5 second delay to show the IntelliSense menu, and that delay is on the main UI thread. So, VS2013 can become unresponsive during that time period.
    • It’s actually gotten so bad, that I fear typing $.
  • Debugging was missing in-depth variable inspection
    • The ability to expand a variable, especially XmlDocument, wasn’t available and very missed.
    • Since the Command Window/REPL isn’t implemented yet, there was no way to dig into a variables inner values with a command line.

Using PowerShell ISE like a Browser

I’ve done a fair amount of web development and have become comfortable with using 2 applications to code in.

  • Visual Studio: Used to write the code
  • Web Browser: Used to execute and somewhat debug the code

So, I found it really comfortable to use the PowerShell ISE along with VS2013:

  • Visual Studio: Used to write the Module code and handle TFS check-ins.
  • PowerShell ISE: Used to write Scripts, Unit Tests, and Debug.

This felt very familiar to me and help differentiate what type of code I was writing. It also helped me to figure out how much time I should be spending on a particular type of code. If I was writing code for a Module, then I could spend extra effort to write unit tests and ensure it’s stability. If I was writing a Script (which a unit test kinda is) then the goal was to get the job done.

image

Potential Issues

Visual Studio 2012 & “Server Workspaces”

Some of our team members have setup their local workspaces using Visual Studio 2012. It looks like VS 2012 doesn’t have the ability to handle “Local workspaces” (at least I got some error pop-ups [no screenshots, sorry]). This could mean that all the files that get pulled down in a workspace that’s created with VS2012 will be in a “Server workspace”. And in Server workspaces, all the files are going to be Read Only when checked-in. I would imagine that would create a lot of consternation when trying to pull up a file in PowerShell ISE and looking to make a quick edit.

VS2013 has a default workspace type of “Local”, which doesn’t use the Read Only flag on files.

PowerShell Tools VSIX & Multiple Domain Accounts

Some of our team members have multiple domain accounts. The second account is for doing SysAdmin work, like updating Production servers.

It looks like the PowerShell Tools for Visual Studio VSIX will install into an individual user folder. So, if you have two domain accounts you will need to install it using both domain accounts. It can easily be installed using both accounts and will work just fine.

PowerShell ISE Add-Ons

I also tried a few Add-Ons for PowerShell ISE, but every one that I tried just made the ISE unstable and prone to crashing. So, I removed them from my ISE. If you’re interested here is a list of some interesting ones:

(A lot of these you have to hand edit your PowerShell profile to get to load in the ISE)

image

VariableExplorer: Displays the full variable list currently available in the runtime.
FunctionExplorer: Displays a list of all function definitions in a file (very useful!)
CommentSelectedLines: Crazy unstable! But when it works, its fantastic. You can setup which keyboard shortcuts you want to bind to by editing the PowerShell .ps1. And, it adds the ability to save your ISE state when you close it down.
Script Browser: I actually didn’t find this useful, but it’s worth noting because it’s made by Microsoft and it was stable.

 

PSGet

I just wanted to remind myself that PSGet has a good sized directory of useful and up-to-date modules.

0 comments:

Post a Comment


Creative Commons License
This site uses Alex Gorbatchev's SyntaxHighlighter, and hosted by herdingcode.com's Jon Galloway.