Sam*_*ell 11 debugging powershell cmdlets visual-studio
我在Windows 7 64位专业版上使用Visual Studio 2010.我在调试自定义PowerShell cmdlet时遇到问题.
C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe-noexit -command Add-PSSnapIn MyCustomSnapIn问题1:按F5时无法连接(调试→开始调试)
问题2:当我按下Ctrl + F5时,意外启动为32位进程(Debug→Start Without Debugging)
The annoying way to debug right now: The only way I've found to debug my cmdlet is to press F5, then select Debug→Detach All, then select Debug→Attach To Process and reattach Visual Studio.
问题1:
在我看来,这就像VS2010中的一个错误:https: //connect.microsoft.com/VisualStudio/feedback/details/539389/debugging-powershell-cmdlet-from-vs-2010-does-not-stop-at-breakpoints ?WA = wsignin1.0
使用VS2008应该有所帮助.
更新:我找到了更方便的方法来调试PowerShell cmdlet.在解决方案资源管理器中,右键单击解决方案节点 - >添加 - >新建项目 - >选择powershell.exe文件(C:\ Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe).将新添加的项目设置为启动项目(右键单击并选择"设置为启动项目").然后转到项目属性(右键单击项目节点并选择"属性")并将"调试器类型"属性设置为"托管(v2.0,v1.1,v1.0)".不要忘记注册您的Provider或CmdLet(通过运行post build事件,请参阅http://msdn.microsoft.com/en-us/library/ms714644%28v=vs.85%29.aspx).现在,程序应该在断点处停止.
问题 1:powershell.exe 实际上不是托管可执行文件。它托管 CLR 本身,因此您需要启用本机代码调试以及托管代码才能正常工作。
至于问题2,我不太确定。显然 VS 本身是一个 32 位进程,所以它可能会干扰这里。
| 归档时间: |
|
| 查看次数: |
5290 次 |
| 最近记录: |