First let's address a misconception.
Source does not require a URL
Sources can be one of the following formats:
- HTTP/HTTPS OData Feed
- Local Directory
- CIFS Share / UNC share
See https://github.com/chocolatey/choco/wiki/How-To-Host-Feed#local-folder--unc-share-cifs for more information.
Offline cache
We've updated this question based on content at https://stackoverflow.com/a/18596173/18475
We call this process internalization. You can do this manually or look at Chocolatey for Business to do this.
Typically package maintainers on the community package repository do not have distribution rights for the actual software binaries, so the package needs instructions to go download those resources and act on them. This is not a limitation when using Chocolatey internally.
Caching Downloads - Not Deterministic
While there are ways to set the original nupkg (with the version on it, not the one in the packages directory - use download from left side of packages page on the Chocolatey community package repository) and preset the downloaded binaries into the cache folder, it's not always deterministic that it will work. You can also override the cache location, so that the folder is somewhere not in TEMP. See choco config
, choco config -h
and choco config set cacheLocation c:\some\location
to do this.
NOTE: The cache will only support the same architecture, as in you can't take the results from an x64 machine and expect the cache to have 32-bit installers also downloaded.
Create Your Own Packages - Better
For packages you need offline, you have the ability to manage your own packages and you can embed software right into the package. This is desired when you want to manage software offline as most things on the community repository are subject to copyright law and distribution rights (why they don't simply have the software they represent embedded).
Creating and working with your own packages is very secure, but it does tend to take up time. If you are doing this for yourself, then it could override any time-savings you get as a consumer using Chocolatey and the community repository.
For organizations, we've developed Package Builder, which creates full software deployments (packages) in 5-10 seconds. It can also create packages right out of existing installed software (Programs and Features) in under 60 seconds! Read more about Package Builder.
Internalized Packages - Best
The best thing you can do here is a process called internalizing, where you download and extract the package, download all of the resources and embed them in the package (or put them somewhere local), edit the scripts to use those embedded/local resources and recompile the package.
This allows you to take advantage of existing package logic without the issue of the internet.
For more details see Manually Internalizing Packages and Package Internalizer - Automatically Internalize Packages.
Organization Use of Chocolatey
Most organizations using Chocolatey are doing some combination of creating packages and internalizing packages, because they need absolute trust and control over those packages when being used in production scenarios.
You have two options: pin a package in advance, or exclude items during choco upgrade
.
Pin Packages to Suppress Upgrades
You can pin any program you don't want updated.
Type choco pin -h
for more details. If that command doesn't give you anything, please upgrade Chocolatey to at least 0.9.9.x.
Pin Command
Pin a package to suppress upgrades.
This is especially helpful when running choco upgrade
for all
packages, as it will automatically skip those packages. Another
alternative is choco upgrade --except="pkg1,pk2"
.
Usage
choco pin [list]|add|remove [<options/switches>]
Examples
choco pin
choco pin list
choco pin add -n=git
choco pin add -n=git --version 1.2.3
C4B: choco pin add -n=git --version 1.2.3 --reason "'others may need to review'"
choco pin remove --name git
NOTE: --reason
option ONLY available in Chocolatey for Business (C4B).
Exclude Packages While Upgrading
Sometimes you just simply want to exclude items you would normally include in upgrades. You don't want pins as those are meant to live longer than a single command run. That is where the Exclude
option comes in to your upgrade command.
As of Chocolatey v0.9.10, when calling upgrade, you can pass the optional --except
as a switch for upgrade. An example would be choco upgrade all --except="'conemu'"
.
Best Answer
Currently, there is no way to do what you are asking.
Each Chocolatey package is unique in the sense that it could be a wrapper around an MSI or an EXE, or it could be a simple extraction of a compressed archive to a known location i.e. C:\tools, or it could be a PowerShell module that extracts to PSModulePath, or it could be something completely custom.
This is a side effect of the Windows ecosystem, where there are multiple ways to do the same thing. Chocolatey is trying to bring some sort of order to this by providing a mechanism to at least find all the packages that you want in one place, but there is only so much Chocolatey can do.
If you look at things completely differently, it is possible to pass installation arguments to a Chocolatey package using the following:
https://github.com/chocolatey/chocolatey/wiki/CommandsInstall#installarguments-optional---v09813
This could, in theory, alter the installation arguments of an MSI or EXE based Chocolatey package to change where the files are installed to. You can see an example of this approach being used here:
http://chocolatey.org/packages/VisualStudio2013Ultimate
However, this approach is limited. Not everyone takes the time like Matt to mention the possible installation arguments that are possible, and it is quite a convoluted process to extract the installation arguments that are possible to be sent into an MSI or EXE.
In terms of ChocolateyGUI, and as the current maintainer of that product, I can tell you that it does nothing clever in this area :-). It is simply a wrapper around the command line tools that Chocolatey provides, and aims to make it easier for people who don't like using the command line.