3

I'm writing some BoxStarter scripts for unattended installation.

I've put some Write-Debug in my scripts and would like to conditionally see their output. Is there a flag I could run BoxStarter with (BoxStarter.bat PackageName -Debug don't works)?

Same debugging idea: Is there a way to make BoxStarter/Powershell tell at which file and line it found the fatal error that makes it stop? I know BoxStarter packages get packed into a .nupkg file but maybe is there a way to retrieve original file and line?

CDuv
  • 2,098
  • 3
  • 22
  • 28

1 Answers1

3
  1. If you use write-debug then the output will appear in c:\chocolatey\chocolateyinstall\chocolateyinstall.log

  2. To get good stacktrace info, I suggest wrapping the contents of your package in a try catch and in your catch block have it include:

Write-ChocolateyFailure 'MyPackage' $($_.Exception.ToString())

olydis
  • 3,192
  • 13
  • 28
Matt Wrock
  • 6,590
  • 29
  • 23
  • Fixed command (cannot edit answer: fix is too short): `Write-ChocolateyFailure 'MyPackage' $($_.Exception.ToString())` Gives more info indeed. – CDuv Apr 24 '14 at 16:21