我有一个 ps1 脚本来驱动我想要执行的操作。我在使用命令模式的模块中使用具有类定义的模块。
第一次打开powershell会话控制台并运行脚本时,一切都很好。
如果我以任何方式更改一个类并在同一个控制台中重新运行,控制台似乎没有拾取更改后的脚本。我必须关闭 powershell 控制台并重新运行脚本才能使我的更改生效。否则,我只会让脚本的行为与我进行更改之前的行为相同。显然有一些缓存正在进行。
我想知道MS是否最终解决了这个问题。我读过很多关于这个问题的旧帖子。
我尝试了以下方法,但它们似乎都不起作用:
Remove-Variable * -ErrorAction SilentlyContinue; 删除模块 *; $error.Clear(); 清除主机
我什至都试过了。仍然没有帮助。
是否可以采取其他措施来确保加载任何支持模块中的最新代码?必须关闭整个控制台并重新加载是一个严重的生产力问题。
我在做什么的例子:6
using module .\Logger.psm1
using module .\AzurePlatformParmsDefault.psm1
using module .\AzurePlatform.psm1
[Logger] $Logger = [Logger]::Create()
[AzurePlatformParms] $AzurePlatformParms = [AzurePlatformParmsDefault]::Create( $Logger )
[AzurePlatform] $AzurePlatform = [AzurePlatform]::Create( $Logger, $AzurePlatformParms )
[bool] $Result = $AzurePlatform.Execute()