如何调试install.ps1的NuGet包的脚本 [英] How to debug install.ps1 script of NuGet package

查看:777
本文介绍了如何调试install.ps1的NuGet包的脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此​​,我们可以包含在一个包中的NuGet的安装/卸载PowerShell脚本。我试过了,但我的install.ps1不起作用。是否有可能找出原因?调试,日志记录,什么?

So we can include an install/uninstall powershell scripts in a NuGet package. I tried, but my install.ps1 does not work. Is there any possibility to find out why? Debugging, logging, anything?

更新

请注意,脚本作为包装的NuGet的安装过程的一部分执行。这可能是非常的NuGet特定的。

Please note that the script is executed as part of an installation process of Nuget package. It may be very Nuget-specific.

推荐答案

也许我迟到了,但这里是调试的NuGet特定的脚本解决方案,该包的NuGet NuGetDebugTools 。它的脚本附加Debugger.ps1 增加了一个简单而有效的调试器的的NuGet包。Manager控制台

Perhaps I am late to the party but here is a solution for debugging NuGet specific scripts, the NuGet package NuGetDebugTools. Its script Add-Debugger.ps1 adds a simple and yet effective debugger to the NuGet package manager console.

示例场景:


  • 启动Visual Studio

  • 开放的NuGet控制台,输入命令

  • start Visual Studio
  • open NuGet console and type commands

PM> Add-Debugger [-ReadHost]
PM> Set-PSBreakpoint -Command init
PM> Set-PSBreakpoint -Command install


(或设置更具体的断点,请参阅帮助设定PSBreakpoint

(or set more specific breakpoints, see help Set-PSBreakpoint)


  • 打开Visual Studio解决方案或者调用安装封装为XYZ已经打开

  • 出现在任何的 init.ps1 的调试器输入对话框和 install.ps1 的调用

  • 类型?作为调试器的输入,看看你可以做什么:

  • open a Visual Studio solution or invoke Install-Package XYZ for already opened
  • the debugger input dialog appears on any init.ps1 and install.ps1 invoked
  • type ? as debugger input and see what you can do:

s, StepInto  Step to the next statement into functions, scripts, etc.
v, StepOver  Step to the next statement over functions, scripts, etc.
o, StepOut   Step out of the current function, script, etc.
c, Continue  Continue operation (also on empty input).
q, Quit      Stop operation and exit the debugger.
?, h         Display this help message.
r            Display PowerShell command history.
k            Display call stack (Get-PSCallStack).
<number>     Show debug location in context of <number> lines.
+<number>    Set location context preference to <number> lines.
<command>    Invoke any PowerShell <command> and write its output.


  • 键入其他调试器和PowerShell命令并观察的NuGet控制台输出

  • type other debugger and PowerShell commands and watch the output in the NuGet console

    V1.4.0 - 新开关 ReadHost 告诉使用读主机输入,而不是默认的GUI输入框。

    v1.4.0 - New switch ReadHost tells to use Read-Host for input instead of the default GUI input box.

    这篇关于如何调试install.ps1的NuGet包的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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