diff --git a/src/chocolatey.resources/helpers/functions/Install-ChocolateyInstallPackage.ps1 b/src/chocolatey.resources/helpers/functions/Install-ChocolateyInstallPackage.ps1 index 0dc8e81920..5cdea6f164 100644 --- a/src/chocolatey.resources/helpers/functions/Install-ChocolateyInstallPackage.ps1 +++ b/src/chocolatey.resources/helpers/functions/Install-ChocolateyInstallPackage.ps1 @@ -201,6 +201,21 @@ Pro / Business supports a single, ubiquitous install directory option. $silentArgs = $silentArgs -replace '\\chocolatey\\chocolatey\\', '\chocolatey\' $additionalInstallArgs = $additionalInstallArgs -replace '\\chocolatey\\chocolatey\\', '\chocolatey\' + try { + # make sure any logging folder exists + $pattern = "(?:['`"])([a-zA-Z]\:\\[^'`"]+)(?:[`"'])|([a-zA-Z]\:\\[\S]+)" + $silentArgs, $additionalInstallArgs | %{ Select-String $pattern -input $_ -AllMatches } | + % { $_.Matches } | % { + $argDirectory = $_.Groups[1] + if ($argDirectory -eq $null -or $argDirectory -eq '') { continue } + $argDirectory = [System.IO.Path]::GetFullPath([System.IO.Path]::GetDirectoryName($argDirectory)) + Write-Debug "Ensuring '$argDirectory' exists" + if (![System.IO.Directory]::Exists($argDirectory)) { [System.IO.Directory]::CreateDirectory($argDirectory) | Out-Null } + } + } catch { + Write-Debug "Error ensuring directories exist - $($_.Exception.Message)" + } + if ($fileType -like 'msi') { $msiArgs = "/i `"$file`"" if ($overrideArguments) {