chocolatey / choco

Chocolatey - the package manager for Windows
https://chocolatey.org
Other
10.34k stars 903 forks source link

ScheduledTasks PowerShell module produces 'Progress' output when used in a package during install #3331

Open MickaelRoy opened 1 year ago

MickaelRoy commented 1 year ago

Checklist

What You Are Seeing?

Whether Chocolateuinstall.ps1 contains any cmdlets regarding ScheduledTasks powershell module, Choco.exe detects it as a download process and show "Progress: 100% - 1/1 completed"

The issue disappear if I run with --no-progress parameter.

What is Expected?

Nothing is expected, that's the point

How Did You Get This To Happen?

I ran choco instal mypackage chocolateyinstall.ps1 contains $PostInstallTask = Get-ScheduledTask -TaskName 'Citrix VDA post installation' -TaskPath \ -ea 0 -InformationAction SilentlyContinue Progress: 100% - 1/1 completed

System Details

Installed Packages

chocolatey

Output Log

https://gist.github.com/MickaelRoy/11d9e64b0496746dc4d9e1724cac43a1

Additional Context

No response

pauby commented 1 year ago

We are unable to reproduce these steps without mypackage. Can you provide:

  1. mypackage
  2. The full Chocolatey log. The gist doesn't have the full details.

Note that --no-progress only does not show the download progress percentages bar. From choco instal -?:

     --no-progress
     Do Not Show Progress - Do not show download progress percentages.
MickaelRoy commented 1 year ago

you can find the package here https://github.com/MickaelRoy/Chocolatey Gist has been updated with log generated fron another/similar host.

I know that --no-progress concerns download process. this is why I raise this bug. the package don't need anything else than executing a command from scheduledtasks module to trigger this useless information.

I observe this issue no metter on Server and desktop OS edition.

pauby commented 1 year ago

Can you provide a screenshot of the useless information?

The gist provides the word 'progress' twice, and neither of them are the message you mention.

MickaelRoy commented 1 year ago

Sorry, it seems that i'm not clear.... the screenshot is right beside the package you asked. https://github.com/MickaelRoy/Chocolatey/blob/main/2023-09-22_14h06_10.png

pauby commented 1 year ago

So I can reproduce this issue but it appears to be coming from Get-ScheduledTask rather than ChocolateyCLI. I amend the chocolateyInstall.ps1 from the package to add this:

Write-Warning "Before"
$PostInstallTask = Get-ScheduledTask -TaskName 'Citrix VDA post installation' -TaskPath \ -ea 0 -InformationAction SilentlyContinue
Write-Warning "After"
Get-ScheduledTask -TaskName 'Citrix VDA post installation' -TaskPath \ -ea 0 -InformationAction SilentlyContinue
Write-Warning "After Again 1"
$abc = Get-ScheduledTask -TaskName 'Citrix VDA post installation' -TaskPath \ -ea 0 -InformationAction SilentlyContinue
Write-Warning "After Again 2"

(Note that the rest of that script didn't change). I then ran choco install mypackage -vd and got this:

image

Which shows that the Progress 100% (1/1) is coming from that cmdlet rather than Chocolatey CLI.

Running choco install mypackage -vd --no-progress does show:

image

Which means either Chocolatey CLI is identifying the text and consuming it (perhaps because it contains the word 'Progress') or we have special handling for that cmdlet which I don't think we do and cannot find.

Having said all of that, if you run Get-ScheduledTask -TaskName 'Citrix VDA post installation' -TaskPath \ -ea 0 -InformationAction SilentlyContinue, you get:

image

(i.e. none of the text we saw above).

My workaround, for now, would be to run it with --no-progress as you identified. So I'm a little confused.

pauby commented 1 year ago

As an update, if you run choco install mypackage --use-system-powershell it works as expected, so it's in the PowerShell host that Chocolatey CLI spins up:

image

MickaelRoy commented 1 year ago

so am I (confused)

putting each time --no-progress is a little boring. it should be great to get a variable of something to put directly in the chocolatey(un)intall.ps1

I don't understand what those cmdlets do to trigger {choco download progress detection} but the legacy command SchTasks.exe looks not concerned by this behaviour.

Edit. Ok this last point is explained by your last comment about --use-system-powershell, dos command is not concerned by powershell drifts

pauby commented 1 year ago

See the comment I left above. The issue is in the PowerShell host that Chocolatey CLI creates to run the PowerShell script. The workaround, until the bug is fixed, is to add either --no-progress or --use-system-powershell. Both of those remove the text that you don't want.