-
Notifications
You must be signed in to change notification settings - Fork 511
Local powershell module changes do not persist, seemingly due to cacheing. #1079
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
Comments
I've found one workaround is to place But it seems to me the problem stems from re-using the same Powershell process. As a developer when I start a debug instance I expect it to be a new instance, not containing state from the previous instance. Perhaps a solution would be to add a launch.json option to start a new PS terminal with each launch, and include that as the default setting for the launch current PS file config? |
I understand that this feature was added to better emulate folks experience with the ISE editor. It is not my preference though. Fortunately there is a setting you can enable to force a fresh session:
Please try this setting and let me know if it meets your needs enough to close this issue. |
Thanks for the reply. This seems like a better solution, but the new console immediately closes after run. As such you don't get a chance to check the output. Is there some way to set it to only close the terminal when you start a new run? |
Yup, I noticed the same thing. I'm closing this as a duplicate of #907. Feel free to add feedback/suggestions on that issue. |
Any news on this? This is pretty annoying. I am currently debugging my functions to a ps1 file before moving them to the psm1 file. When I am not doing that then I am trashing the Powershell Session with the bucket icon. It then asks me if I want to restart a session to which I reply "Yes". But that's 2 more actions than I would like. |
For my PowerShell modules, I use the following in my testing .ps1's: Import-Module"$PSScriptRoot\MyModuleName.psd1"-Force #I always have psd1's for each of my psm1's |
Have you tried adding |
PowerShell does not reload a module by default, it uses a cache. You get the new module when you restart PowerShell because you dump the old PowerShell process. There's not much the extension can do for you here -- you need to use |
Noted and implemented! Thanks! :) |
System Details
$PSVersionTable
: (Below. Seems to be duplicated in your template)Issue Description
I am a: developer. I want to: Modify a Powershell module in a local psm1 file and test those changes using a Powershell script (ps1) in the same folder, using the "PowerShell Launch Current File" default configuration.
What I expect to happen: When I make a change in the psm1 file, these changes should persist when I run the ps1 script referring to that module.
What actually happens: Running the script uses an old version of the module. Restarting Visual Studio Code seemingly refreshes the cache, resulting in the changes now being present in the script's behaviour.
Steps to Recreate
test.psm1
.function test() {...}
Write-Host "hello world"
.Export-ModuleMember test
test.ps1
in the same folder that imports the module, i.e.Import-Module .\test.psm1
.test()
The text was updated successfully, but these errors were encountered: