Chocolatey is a package manager similar to Linux apt and yum to create, update, distribute and remove software packages in a centralized and automated manner.

Two are the platforms at its basis: NuGet and Windows PowerShell. The former is a .NET package manager on its turn, and the former is the well-known integrated shell of the Microsoft Windows world. Available both as a command line tool and with a GUI, Chocolatey is an open source project with three licensing models: free, Pro and Business, with the additional MSP and Architect plans for specific uses.

The free version is the one with the least number of features and without the official support; limitations include not being able to create your own packages, convert existing ones or have the centralized console dashboard. The Pro version is for up to 8 computers and any business usage is forbidden; the price is $96 per year and includes official support via email and advanced features like graphic Package Builder. The Business license is more structured with packages whose price varies according to the number of computers where Chocolatey will be installed. This version doesn’t have any restriction in terms of features and has a complete support. Then we have two editions for specials cases: the MSP one, distributed with at least 200 licences, and the Architect, which is conceived for development purposes and has an aggressive price. You can find a recap table here.

Chocolatey in action

Being a package manager, Chocolatey includes the main features we expect from such a product: installation, update, dependencies management, automated uninstall and auditing. For that, you can deploy a dedicated server, which will also host the packages’ repository.
Chocolatey doesn’t have any high requirements in terms of computational resources, it just needs Windows 7 or later (equivalent to Windows Server 2003 or later), PowerShell 2 or alter and .NET 4.x or later - if not available, it will be automatically downloaded and installed. The installed is a simple script that can be run from a shell (with admin privileges) or PowerShell (documentation here). Once the installation is complete, simply try it by writing choco or choco -?. Should the Internet installation fail, an offline package is available.


choco gui installNote that the basic installation installs a trial version, and the use of a licence requires an activation procedure. According the version, you can update the platform with a command as simple as choco upgrade chocolatey, exactly as you would do for other packages. After Chocolatey is up and ready, packages can be installed with choco install package-name. A wide assortment of additional options can be passed as parameters, for instance a different installation folder than the default one.

Similarly to Linux, additional parameters can be passed with characters combinations that include -, / and _ according to the type of parameter. For instance single characters options can be called with /; other specific-feature characters are = and =! to evaluate options, -d for debug, -v for the extended description (verbose) and -y for automatic yes to prompts.

Key concepts about Chocolatey

Three are the phases that involve the life of a package: installation, update and removal. Let’s see how to do that.

We’ve seen previously how Chocolatey is based on NuGet: thanks to this platform if can actually perform the installation. NuGet collects the package from the source: it can be a local folder, a network share or a repository on the Internet. Both http and https are supported.
As in Linux, source repositories can be added and removed manually according to needs (eg: you deployed your own and want to add it to the list). Standard installation path is ChocolateyInstall\lib\ and can’t be configured inasmuch is also used to track the life of the package in order to better update or remove it. Indeed, Chocolatey checks whether the package requires any dependencies and creates a registry snapshot before and after the installation, and a special file with all information for the proper removal.

Then the software checks the presence of executable files in the working directory and generates libraries (Shims: they translate API calls and any arguments passed with the command) that are made available the the final package in the \bin folder.

Updating a package happens in a similar fashion: Chocolatey creates a snapshot of the package’s folder before trying to update so that a rollback can be performed if anything goes wrong. Be careful because the snapshot includes only the directory of the package, so any additional integration and external references will be lost.

Lastly, the removal of a package happens by launching the script included in the package’s folder, after backing up the folder itself. Once the procedure is complete, if empty, the folder itself will be removed.

Here’s the syntax to use for each of the three situations:

choco install <pkg|package.config> [<options/switches>]
choco upgrade <pkg|all> [<options/switches>]
choco unistall <pkg|all> [<options/switches>] oppure cunist <pkg|all> [<options/switches>]

Adding a repository:

choco source [list]|add|remove|disable|enable [<options/switches>]

Chocolatey can also work with software already installed on the machine, so it can integrate with the already-present environment and be used to install a certain packages without impacting on any other on the system.
Of course most times we don’t know the exact name of the package to install: the search command comes handy as it helps to search the package locally and remotely. The three main usages are:

choco search <filter> [<options/switches>]
choco list <filter> [<options/switches>]
clist <filter> [<options/switches>]

The last one is a shorteed version of the previous one.

Creating packages


Within Chocolatey, a package is a nupkg file (or a zip file) compiled with NuSpec that is completely autonomous regarding metadata, dependencies and versioning. It’s clearly an advanced version of the simple aforementioned NuGet package as it contains many more additional information required by Chocolatey to run correctly.
First of all, you can create a self-contained package or an automated script: maintaining a package will be easier and more sager with the former, while the latter involves PowerShell to run such script.
The minimum requirement to create packages are NuSpec and XML files that describe the package itself (ie defining dependencies).

The basic command is:

choco new <package_name>

A brief example of a package with http source might be:

$packageName = ‘gurupackage’
$fileType = ‘exe’
$url = ‘http://download.guruadvisor.net/packages/gurupackage.exe’
$silentArgs = ‘-y’
Install-ChocolateyPackage $packageName $fileType $silentArgs $url

The Business version includes a graphic Package Builder, a tool that simplifies a lot the creation of packages: all you have to do is to select the executable file or the zip archive, select the “Create Chocolatey package” button and specify an output folder.


choco gui


Concluding, Chocolatey integrates perfectly with several automation platform like Ansible, Boxstarter, Chef, PowerShell DSC, PowerShell PackageManagement and others listed here.

About the Author

Lorenzo Bedin

Lorenzo graduated in Telecommunication Engineering and works as freelance IT consultant, after a period of training as systems analyst. Currently he provides hardware solutions, virtualized infrastructures and websites.

banner eng

fb icon evo twitter icon evo

Word of the Day

In the field of Information Technology, the term piggybacking refers to situations where an unauthorized third party gains access to...

>

The acronym GDPR indicates the new General Data Protection Regulation, which will come into force on 25 May 2018. This...

>

The acronym DPO (Data Protection Officer) indicates the person or persons who, within the company context, are responsible for the...

>

InfiniBand is an input / output architecture for the transmission of data between high performance systems composed of CPUs, processors...

>

A Zero Day Exploit describes a situation in which specific and unknown vulnerabilities are disclosed to the public simultaneously with...

>
Read also the others...

Download of the Day

Netcat

Netcat is a command line tool that can be used in both Linux and Windows environments, capable of...

>

Fiddler

Fiddler is a proxy server that can run locally to allow application debugging and control of data in...

>

Adapter Watch

Adapter Watch is a tool that shows a complete and detailed report about network cards. Download it here.

>

DNS DataView

DNS DataView is a graphical-interface software to perform DNS lookup queries from your PC using system-defined DNS, or...

>

SolarWinds Traceroute NG

SolarWinds Traceroute NG is a command line tool to perform advanced traceroute in Windows environment, compared to the...

>
All Download...

Issues Archive

  • GURU advisor: issue 18 - April 2018

    GURU advisor: issue 18 - April 2018

  • GURU advisor: issue 17 - January 2018

    GURU advisor: issue 17 - January 2018

  • GURU advisor: issue 16 - october 2017

    GURU advisor: issue 16 - october 2017

  • GURU advisor: issue 15 - July 2017

    GURU advisor: issue 15 - July 2017

  • GURU advisor: issue 14 - May 2017

    GURU advisor: issue 14 - May 2017

  • GURU advisor: issue 13 - March 2017

    GURU advisor: issue 13 - March 2017

  • GURU advisor: issue 12 -  January 2017

    GURU advisor: issue 12 - January 2017

  • GURU advisor: issue 11 -  October 2016

    GURU advisor: issue 11 - October 2016

  • 1
  • 2
  • 3
  • BYOD: your devices for your firm

    The quick evolution of informatics and technologies, together with the crisis that mined financial mines, has brought to a tendency inversion: users that prefer to work with their own devices as they’re often more advanced and modern than those the companies would provide. Read More
  • A switch for datacenters: Quanta LB4M

    You don’t always have to invest thousands of euros to build an enterprise-level networking: here’s our test of the Quanta LB4M switch Read More
  • Mobile World Congress in Barcelona

    GURU advisor will be at the Mobile World Congress in Barcelona from February 22nd to 25th 2016!

    MWC is one of the biggest conventions about the worldwide mobile market, we'll be present for the whole event and we'll keep you posted with news and previews from the congress.

    Read More
  • 1