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?
Update
Please note that the script is executed as part of an installation process of Nuget package. It may be very Nuget-specific.
In order to debug into NuGet package libraries, Visual Studio must be configured to use ProGet as a symbol server. To do this select Debug > Options, from the menu bar, then browse to Debugging > Symbols in the tree menu.
Either make an account on the Nuget.org website, then log in, browse to the package you want and click on the Download link on the left menu. Then simply unzip the . nupkg file and extract the contents you need.
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.
The sample scenario:
open NuGet console and type commands
PM> Add-Debugger [-ReadHost] PM> Set-PSBreakpoint -Command init PM> Set-PSBreakpoint -Command install
(or set more specific breakpoints, see help Set-PSBreakpoint
)
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.
type other debugger and PowerShell commands and watch the output in the NuGet console
v1.4.0 - New switch ReadHost
tells to use Read-Host
for input instead of the default GUI input box.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With