调试/卸载 PowerShell Cmdlet [英] Debugging / unloading PowerShell Cmdlet

查看:47
本文介绍了调试/卸载 PowerShell Cmdlet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Visual Studio 2015 在 C# 中编写 PowerShell Cmdlet.调试它工作正常,但在关闭 PowerShell 窗口之前我无法重建 DLL.DLL 似乎正在使用中,因此无法删除(不在命令行上或使用资源管理器).我试过删除模块.这成功删除了我的 Cmdlet,但我仍然无法删除/覆盖它.

I am writing a PowerShell Cmdlet in C# using Visual Studio 2015. Debugging it works fine, but I cannot rebuild the DLL until I close the PowerShell window. The DLL seems to be in use and therefore cannot be deleted (not on the command line nor using explorer). I tried remove-module. This successfully removes my Cmdlet but I still cannot delete / overwrite it.

关闭PowerShell,重建DLL,然后重新打开一个新的PowerShell,cd到DLL路径(通常是深度嵌套),再次重新导入,启动命令进行调试,等等每一个都非常不方便调试会话...

It is very unhandy to close PowerShell, rebuild the DLL and then reopen a new PowerShell, cd to the DLL path (usually deeply nested), re-import it again, start the command to debug, and so on for every single debugging session...

有没有更好的办法卸载DLL?

Is there no better solution to unload the DLL?

推荐答案

据我所知,恐怕您对这种行为无能为力.一个技巧是在加载 DLL 之前立即在现有会话中启动一个新的 PowerShell 会话.然后你可以退出第二个,你有一个没有加载 DLL 的全新的.请记住在再次加载之前启动一个新的次要"会话,以防您需要再次卸载它.

I'm afraid there is not much you can do about this behavior as far as I know. One trick is to immediately start a new PowerShell session inside your existing session before loading the DLL. Then you can exit out of the second one and you have a brand new without the DLL loaded. Just remember to start a new "secondary" session before loading it again in case you need to unload it again.

这篇关于调试/卸载 PowerShell Cmdlet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆