How to debug install.ps1 script of NuGet package(如何调试 NuGet 包的 install.ps1 脚本)
问题描述
因此我们可以在 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.它的脚本 Add-Debugger.ps1 为 NuGet 包添加了一个简单而有效的调试器管理控制台.
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
(或者设置更具体的断点,见help Set-PSBreakpoint
)
(or set more specific breakpoints, see help Set-PSBreakpoint
)
- 打开 Visual Studio 解决方案或为已打开的调用 Install-Package 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
告诉使用 Read-Host
进行输入,而不是默认的 GUI 输入框.
v1.4.0 - New switch ReadHost
tells to use Read-Host
for input instead of the default GUI input box.
这篇关于如何调试 NuGet 包的 install.ps1 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何调试 NuGet 包的 install.ps1 脚本
基础教程推荐
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- rabbitmq 的 REST API 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- c# Math.Sqrt 实现 2022-01-01