chocolatey / cChoco

Community resource to manage Chocolatey
Apache License 2.0
154 stars 99 forks source link

Turn off installation progress for cChocoPackageInstall to stop it filling the verbose log output #175

Open rcarpenter79 opened 1 year ago

rcarpenter79 commented 1 year ago

Checklist

Is Your Feature Request Related To A Problem? Please describe.

Yes. Verbose output is a mess when logging installation progress.

cChcocoPackageInstall_Verbose_Output

Describe The Solution. Why is it needed?

Set $ProgressPreferences to 'SilentlyContinue' in InstallPackage before running 'choco install'

Example: I also corrected a typo in $packageInstallOutput.

    $cmd = "choco install $pName $chocoParams"
    Write-Verbose -Message "Install command: '$cmd'"

    $currentProgressPreference = $ProgressPreference
    $ProgressPreference = 'SilentlyContinue'

    $packageInstallOutput = Invoke-Expression -Command $cmd

    $ProgressPreference = $currentProgressPreference

    Write-Verbose -Message "Package output $packageInstallOutput"

Additional Context

No response

Related Issues

No response

corbob commented 1 year ago

@rcarpenter79 have you by chance tested this change? I didn't know Chocolatey picked up the ProgressPreference from the invoking PowerShell session. If you've confirmed it works, would you be interested in creating a Pull Request for this change?

If it doesn't work, then you can likely fix it with passing --no-progress to Chocolatey.

rcarpenter79 commented 9 months ago

@corbob I have updated my fork with the upstream changes and merged my changes. Do you want me to create another merge request now?

corbob commented 9 months ago

@rcarpenter79 no need to open a new pr, just updating the existing one is sufficient.

corbob commented 9 months ago

@rcarpenter79 apologies for the delays in getting to look at this. I was looking at the PR today to hopefully merge it, but I'm not able to reproduce the initial issue. When I run in a test environment, the output explicitly says it's calling choco install notepadplusplus --no-progress and so doesn't have any download progress. Could you verify which version of cChoco you're using? It looks like that was added quite a while ago, so I'm not sure how you could be seeing the download progress: https://github.com/chocolatey/cChoco/blob/f583fee2724283820a4405588c1bf37be4d55518/DSCResources/cChocoPackageInstall/cChocoPackageInstall.psm1#L288-L290