Debugging Modules in PowerShell Studio 2012
PowerShell Studio now makes it easier to debug and run your module projects. You now have the ability to execute and debug a module project directly from the IDE (Supported in PowerShell Studio 2012 v3.1.9 and up).
Debugging a module project:
When debugging (F4) or running (Ctrl + F4) a module project for the first time you will be asked to select a Startup Script:
This Startup Script will be used by PowerShell Studio as an entry point to run or debug the module project. Therefore, it’s important that you explicitly import the module in the script:
The Startup Script will be stored by the module project so you don’t have to select the script every time you wish to test the module. In addition, you have the option to change the Startup Script in the project’s properties.
To change the Startup Script, follow these simple steps:
1. Select the project node in the Project Panel:
2. Go to the Property Panel and edit the Startup Script property:
When debugging a module project, PowerShell Studio will build and export the module then execute the Startup Script. Any trace points and break points contained within the project files will be triggered by the debugger and mapped to the appropriate files:
Debugging a module without a project:
If you need to debug a module that doesn’t have a project, you can utilize PowerShell Studio’s new “Debug with Multiple Files” option.
First open the test script and the module files using PowerShell Studio. Next, debug the test script using the “Debug with Multiple Files” option and select the module files that you wish to debug.
Now the debugger will respond to break points located in the module files:
As you can see, these new features help facilitate the module creation process for any user.