How to get a list of packages from one machine and install in another with Chocolatey?

前端 未结 6 2027
迷失自我
迷失自我 2021-01-31 08:23

Calling clist -l gives me a list of packages with versions:

7zip.install 16.04
ccleaner 5.28.6005
ConEmu 17.3.16.0
...

How do I ge

6条回答
  •  孤城傲影
    2021-01-31 09:10

    I would like to summarize the two general approaches given by other answers to this post.

    1. Export a plain list of package names, and use it to build a cinst command.

    This is aligned with the question as asked: how to clist -l without version information.

    I like the simple answer of clist -l --idonly, but to automate this, one must still account for the first and last lines. So, a simple script is probably necessary -- and on Windows, this is a bit of a pain (which is why this question is even being asked).

    If the primary goal is to backup and re-install Choclatey packages, then there are some good choices without writing your own scripts. Hence the next type of solution...

    2. Export a packages.config file, which can be installed by cinst natively.

    This is a nice way to do it, because installing a packages.config is natively supported by cinst.
    Unfortunately, Chocolatey lacks native support for exporting packages.config.

    Here are a few common ways to export packages.config:

    • Chocolatey GUI
    • bcurran3/choco-package-list-backup - an unofficial package for this purpose
    • Custom scripts (example 1, example 2)

    For background to this approach, and to track progress of a built-in solution, see https://github.com/chocolatey/choco/issues/357.

提交回复
热议问题