Installing and upgrading software has always been a tedious task. For end users, you begin with getting the software followed by downloading and installation.
It is a seemingly smoother process on Linux via the command-line (think apt-get), where few commands install or update software (of course, you still need to find what you need to install). This command line interface is now available for Windows users via the oddly named Chocolatey package manager.
The many options for Windows package or software management can be confusing. NuGet is a package management system for developers — that is, it handles packages and references for projects, thus allowing the developer to concentrate on code.
While NuGet handles packages, Chocolatey handles applications at a system level. So, you would use Chocolatey to install an application such as Puppet on your development machine. It appears Chocolatey is becoming the de facto standard for Windows package and dependency management, but it still is not a standard Windows component.
Chocolatey uses PowerShell along with the NuGet packaging format. (You’ll need to set up PowerShell before reaching for Chocolatey.) To install Chocolatey, open a command prompt and enter the following command:
@powershell -NoProfile -ExecutionPolicy unrestricted -Command “iex ((new-object net.webclient).DownloadString(‘https://chocolatey.org/install.ps1’))” && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
- -NoProfile: This switch suppresses custom profiles to avoid installation conflicts.
- -ExecutionPolicy: You’re downloading code via the internet, so execution policy is set to unrestricted to allow the download.
- -Command: This is the download command of Chocolatey. The command is enclosed in double quotes.
- SET PATH: This adds Chocolatey to the system path, so you can run it from anywhere on the system.
Chocolatey can be installed via NuGet, and it is available as a NuGet package. Once installed, you can use the help switch to get an idea of how to use Chocolatey. Figure A shows a portion of the information returned by the help command (chocolatey /?).
Using the help command line switch to get details on Chocolatey usage.
With Chocolatey installed, you can use it to install software on your machine via two commands:
- cinst (chocolatey install): This command is used to install software packages. The install command has a number of additional options and command line switches; a complete list is available online.
- cuninst (chocolatey uninstall): This command is used to uninstall software packages. It currently supports one optional command line switch to specify the version to uninstall.
The Chocolatey sites provides a gallery of currently available software, and you can easily add your own packages (this requires site registration). The following command installs Firefox on my machine:
This kicks off a silent install, so there’s no need to do anything else. Figure B shows the results of the command.
The following command will remove Firefox from your system:
Once software is installed, you will need or want to keep it updated. The update (or cup) command allows you to quickly update an existing package to the latest version if there is one. The following command(s) demonstrate updating our Firefox installation:
chocolatey update Firefox – or – cup Firefox
The chocolatey command can be shortened to choco, so the previously listed update command could be typed as:
choco update Firefox
Maintaining software is the gist of Chocolatey, but basic installs are only the tip of the iceberg, as it offers more advanced commands for working with Windows components and settings, as well as integrating with Ruby Gems, Python, and more. The WindowsFeatures option allows you to install Windows options via the Deployment Image Servicing and Management tool on the local machine. The following command installs the Telnet client:
choco WindowsFeatures TelnetClient
The online documentation provides more information on the WindowsFeatures option and everything else available.
Tasks like setting a new machine (installing all necessary software) come to mind with a tool like Chocolatey. With Chocolatey installed on your machine, you can use it and its commands with scripts to streamline updates or installations. In addition, there are add-on tools such as Boxstarter that use Chocolatey packages to set up new environments. You can browse the online gallery to get an idea of what else is available via Chocolatey. In addition, the list and search commands can be used to get a list of available software via the command line. The following command lists everything available:
The next command finds everything with ‘ftp’ in its name:
choco list ftp – or – choco search ftp
While Chocolatey is not a tool for everyday users, it is a great utility for techies who want a quick and dirty way to install software. Since first discovering Chocolatey, I have jumped on the bandwagon, and I have used it to keep my collection of machines up and running.
I have not seen official announcements from Microsoft about Chocolatey, though the company’s recent unveiling of OneGet shows that it’s embracing the package manager. Chocolatey is currently the only repository for OneGet (I am sure more will follow).
Are you using Chocolatey? If so, do you think it’s a simpler approach to software installation? If not, do you plan to give it a try? Let us know in the discussion.