Automatically Internalize/Recompile Existing Packages (Business and MSP Editions Only)
There are thousands of existing packages on the community repository that are a tremendous resource when it comes to creating packages that have software that can sometimes be tricky! Unfortunately you may be wary of using those packages without changes because many of those packages are subject to distribution rights and thus have an internet dependency (which creates both [[trust and control issues|CommunityPackagesDisclaimer]]). There is a process for downloading and internalizing packages to use internal or embedded locations for that software that is called internalizing (also known as recompiling).
Chocolatey for Business is able to automatically download packages and resources, edit the scripts, and recompile packages to internalize and remove internet dependencies from those packages, saving you hours of time in [[manually internalizing/recompiling packages|How-To-Recompile-Packages]]!
Call choco download
with options including the name of an existing package for Chocolatey for Business to download and download all existing remote resources.
📝 NOTE: To see all feature videos for Chocolatey for Business, please visit https://chocolatey.org/resources/features#c4b.
When running choco download
in the Business editions, pass the following:
--outputdirectory=VALUE
OutputDirectory - Specifies the directory for the downloaded Chocolatey
package file. If not specified, uses the current directory.
-i, --ignoredependencies, --ignore-dependencies
IgnoreDependencies - Ignore dependencies when installing package(s).
Licensed editions v1.9.0+ Defaults to false.
--recompile, --internalize
Recompile / Internalize - Download all external resources and recompile
the package to use the local resources instead. Business editions only
(licensed version 1.5.0+).
--resources-location=VALUE
Resources Location - When internalizing, use this location for resources
instead of embedding the downloaded resources into the package. Can be a
file share or an internal url location. When it is a file share, it will
attempt to download to that location. When it is an internal url, it
will download locally and give further instructions on where it should
be uploaded to match package edits. Business editions only (licensed
version 1.5.1+).
--download-location=VALUE
Download Location - OPTIONAL - when internalizing, download the
resources to this location. Used with Resources Location (and defaults
to Resources Location when not set). Business editions only (licensed
version 1.8.3+).
--append-useoriginallocation, --append-use-original-location
Append -UseOriginalLocation - When `Install-ChocolateyPackage` is
internalized, append the `-UseOriginalLocation` parameter to the
function. Business editions only (licensed version 1.7.0+). Requires at
least Chocolatey v0.10.1 for `Install-ChocolateyPackage` to recognize
the switch appropriately. Overrides the feature
'internalizeAppendUseOriginalLocation' set to by default to 'False'.
See [[download command|CommandsDownload]] for more information.
Community posts that include Package Internalizer:
- Getting Started With Chocolatey 4 Business & Jenkins CI
- Automating Chocolatey package internalizing with PowerShell
- Recompiling Chocolatey packages
You must have a Business edition of Chocolatey or Chocolatey for MSP. Business editions are great for organizations that need to manage the total software management lifecycle.
You can run choco download
and point it to an existing package name on any remote resource, typically folks point to https://chocolatey.org/api/v2/
and let Chocolatey do all of the work of getting the package and remote resources to recompile the package.
It downloads a package locally. Then it looks at the install script to determine if there are remote resources, which are downloaded to a directory in the package (or with another switch will be placed on a file share or setup for an http location). Then it edits the install script to use the local resources instead and recompiles the package. The process takes about as long as it takes to download the remote resources.
Some packages are already internalized or don't have remote resources. In those cases it will just download the existing package and have it available for pushing to an internal repository.
This feature is in preview, but is able to download/recompile quite a few packages. There are a few that it may have issues with, especially if variables with methods are used (e.g. $(somevar).Replace(".","")
). In those cases it attempts to warn you ahead of time that it cannot handle those yet.
Future versions of the licensed edition will support advanced scenarios such as these.
Unfortunately not all packages on the community repository are created equal, even with the rigorous moderation process. A few packages do not use the built-in functions for acquiring files from the internet, so they don't lend well to automatic recompiling. Typically Chocolatey will let you know when this is the case and allow you to inspect the package to allow you to finish up the next steps of recompiling. As a future enhancement, it's possible this scenario would also be supported, although it is a very small subset of packages that are created in this way.