microsoft / winget-cli

WinGet is the Windows Package Manager. This project includes a CLI (Command Line Interface), PowerShell modules, and a COM (Component Object Model) API (Application Programming Interface).
https://learn.microsoft.com/windows/package-manager/
MIT License
22.54k stars 1.39k forks source link

Support more than 10 packages in winget install bulk mode with a single command #4566

Closed jo-chemla closed 1 week ago

jo-chemla commented 1 week ago

Description of the new feature / enhancement

Following support for winget install/uninstall/upgrade bulk mode install of multiple packages within a single command, it seems that there is a hard limit of 10 packages that can be processed at once - just tested it with install on a fresh computer.

It could be great to support an arbitrary count of packages in a single command.

Tested command, ffmpeg won't install as it's the 11th package of the command

doskey winget-multi-install=winget install --disable-interactivity --accept-source-agreements --accept-package-agreements $*

winget-multi-install 7zip.7zip Mozilla.Firefox VideoLAN.VLC OBSProject.OBSStudio Microsoft.VisualStudioCode Microsoft.WindowsTerminal TheDocumentFoundation.LibreOffice SomePythonThings.WingetUIStore GitHub.GitHubDesktop BlenderFoundation.Blender Gyan.FFmpeg 

Proposed technical implementation details

This might originate from the batch limitation of 10 args. Could the more than 10 packages be passed as a single arg, for example as a string variable winget install "pkg1 ... pkg15"? Or could some inspiration be taken from this StackOverflow post?

denelon commented 1 week ago

I believe in this case, the issue is the limit of 10 arguments in a batch file.

Have you tried winget export and winget import? They are a bit more optimized for dealing with a set of packages.

You could fairly easily modify the contents of the JSON file to suit your needs and save some typing.

It might also be worth taking a look at WinGet Configuration which can do considerably more than just install packages.

florelis commented 1 week ago

There is a hard limit to the number of args, but it is actually 128.

I just tried the command you shared and it seems to work correctly for me. It did install only 10 packages, but that was because Windows Terminal was already installed and it got skipped.

What version of winget are you using? Do you see any error in the logs? These can be found with winget --logs

jo-chemla commented 1 week ago

Hey there, not exactly sure what happened, I tested again on another machine the winget install command with >10 packages (~30, out of which 17 did install because the others were already satisfying the latest version). It might indeed have come from an earlier winget version - I don't have access to this machine anymore.

Thanks also for pointing out at WinGet Configuration (looks a bit like ansible winget although not live) and winget import/export, this might indeed be very useful!