-
Notifications
You must be signed in to change notification settings - Fork 500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debug psm1 files. #133
Comments
Hah! I'm surprised that putting One thing that we need to do (which I can't find the bug for at the moment) is to call Do you have any ideas on what else we might be able to do to enable better module debugging? |
I don't think you need to Invoke-PSake to debug your PSM1 file. PSake is more of a build tool. I also don't think you need to modify launch.json. Just create a debug harness script like this: # DebugModule.ps1
Import-Module $PSScriptRoot\YourModule.psm1
# Put in a call to a module method you want to step into and set a breakpoint here Then just have this file open in the active editor window when you start debugging. Another option is to use Pester to write tests for your module. This is what I recommend. This provides two benefits - 1) you now have tests you can run anytime to check for regressions and 2) the execution of those tests can help you debug your functions. Just open a Pester test file (.ps1) and set a breakpoint on a call to one of your module functions. Then start debugging with the Pester file open. For an example of this, open the Examples folder in the PowerShell extensions install dir ( |
Hi,
I can't find a standard way to debug functions in psm1 files.
I've hacked together that more or less works for me now but it's incomplete:
This works rather well if you are debugging modules with only one exported command and that doesn't require any parameters.
The text was updated successfully, but these errors were encountered: