Search code examples
chocolatey

Exclude Dependencies from Chocolatey export for packages.config


Chocolatey has recently enable support for exporting all currently installed packages using choco export command. This export includes all the packages, including the dependencies of tools that I actually care about. Is it possible to exclude these dependencies from the export?

For example, when I install Adobe Reader using choco install adobereader, it also installs kb2919355 as well since that's a dependency for Adobe Reader now. But I don't want kb2919355 to be listed in the exported packages.config because dependencies might change in the future and the dependencies will anyways be installed even if its not specifically mentioned in the list.


Solution

  • I don't believe Chocolatey keeps track between what was automatically installed as a dependency, and what you have manually installed. It gets evaluated at install time of course but it all goes into Chocolatey's lib or lib-bad folder depending on package installation success or failure respectively. This is the extent of package installation tracking, at least in the free version (I can't speak to the administration of the licensed versions).

    In other words a package is either present or absent, not "manually installed" or "automatically installed as a dependency of X, Y, and/or Z packages".

    To this point you should have a solid understanding of your top-level software requirements at least, so do a choco export, then remove dependency packages from packages.config accordingly. Alternatively, you can create your own packages.config and simply don't rely on choco export to create the file for you in the first place.

    Note: This is more meant to be a quick backup solution of the package state of a machine; what you are trying to do is replace a proper configuration management solution with Chocolatey, which not a tenable or scalable solution long term. I suggest learning a real config management tool to manage machine state long term rather than relying on packages.config since package installation is really only one piece of configuration, while continuing to use Chocolatey to manage package/software installations from said config management solution.