Reminder: You can debug PowerShell (even modules!)
Scenario
I made a small change in a COMMENT in a PowerShell module.
Result
Our build server puked on me. I rebuilt a couple of times, 'cause "I didn't do anything!" Slight frustration.
Fix
OK, find the offending code (CTRL+G in VSCode to go to the exact line). Some "Export-NUnitXml" function exported from a PowerShell Module.
- Declare all variables up to the point of the failure
- Add a breakpoint: Set-PSBreakpoint -script ".\.build\tasks\Export-NUnitXml.psm1" -Line 21
- Run the function in VSCode's terminal
- Breakpoint hit.
- Find offensive code that just decided to show up today
- Fix it.
Debugging makes things easier.
Comments