How to debug install.ps1 script of NuGet package

后端 未结 5 391
闹比i
闹比i 2020-12-22 22:52

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,

5条回答
  •  情话喂你
    2020-12-22 23:14

    You might call Start-Transcript at the beginning of install script and Stop-Transcript at the end. You would probably wrap the install code like this:

    try {
      $ErrorActionPreference = 'stop'  # stop on error
      Start-Transcript c:\a.txt
      ...
    }
    catch {
      write-host $_
    }
    finally {
      Stop-Transcript
    }
    

    Also $ErrorActionPreference = 'inquire' (instead of stop) could possibly work. However, no chance to try it now. See http://tasteofpowershell.blogspot.com/2008/07/handling-errors-in-powershell.html

提交回复
热议问题