Skip to content

Commit

Permalink
(chocolateyGH-520) Fix: Debug/Verbose messages not logged
Browse files Browse the repository at this point in the history
`Write-Debug` / `Write-Verbose` messages are not being logged when
coming from the `chocolateyInstall`/`chocolateyUninstall` scripts. This
is due to `DebugPreference` / `VerbosePreference` being only set to
script level in the module and not global.

Instead of changing a global variable, also set the Debug and Verbose
preferences in the script runner. It is thought that changing a global
variable could have other unintended consequences if someone was
running these scripts directly from PowerShell. So prefer the script
level change.
  • Loading branch information
ferventcoder committed Dec 28, 2015
1 parent 4643bab commit df92199
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/chocolatey.resources/helpers/chocolateyScriptRunner.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
[string]$packageScript
)

$DebugPreference = "SilentlyContinue"
if ($env:ChocolateyEnvironmentDebug -eq 'true') { $DebugPreference = "Continue"; }
$VerbosePreference = "SilentlyContinue"
if ($env:ChocolateyEnvironmentVerbose -eq 'true') { $VerbosePreference = "Continue"; $verbosity = $true }

Write-Debug "Running 'ChocolateyScriptRunner' for $($env:packageName) v$($env:packageVersion) with packageScript `'$packageScript`', packageFolder:`'$($env:packageFolder)`', installArguments: `'$installArguments`', packageParameters: `'$packageParameters`',"

## Set the culture to invariant
Expand Down

0 comments on commit df92199

Please sign in to comment.