I have a collection of PowerShell functions that I include in a PowerShell module. I use Plaster to generate .psd1 and .psm1 files from multiple .ps1 source script files that typically contain a single function.
I’m having difficulty coming up with a workflow that allows me to effectively debug modifications of a function. I am using VS Code (so much better than the PowerShell ISE!) and its debugger. The problem is that when I have modified code, PowerShell sometimes (but not always) keeps executing a previous version of the code. I haven’t found a reliable means of executing the modified code.
I’ve tried doing things like using Remove-Module to remove my module then dot-sourcing the modified file in the hope that when I invoke the function, the updated code will be executed. Sometime this works and sometimes it doesn’t. The most reliable procedure seems to be using Plaster to re-generate the module then deploying to the first folder in the ModulePath.
Is there a recommended way to debug code in a module?