What is Chocolatey
Chocolatey is a global automation tool that makes use of PowerShell and the NuGet infrastructure to allow you to do virtually anything. It is kind of like apt-get, but for Windows (with windows comes limitations).
Did he just say package manager for Windows!?? Yes! OOOH AHHH! Listen and take note. Remove the complexity and aggravation out of installing and updating applications or a series of applications with Chocolatey. Simply type a few commands in PowerShell or the command prompt then let Chocolatey do the rest. You will never want to install an application on windows by double clicking an MSI again! Enough talk, time to install Chocolatey and explore the sweetness.
Like any installation before we install anything, review the requirements, review installation options, and determine if there is a desire to alter any custom settings. Minimum requirements for Chocolatey is PowerShell 2.0 and .NET 4.0. By default Chocolatey installs to
C:\NuGet. If you’d like to customize the installation directory, you
MUST change this BEFORE installation. Follow the steps below.
- Create an environment variable named
ChocolateyInstalland set it to the folder you want Chocolatey to install to.
- Create the folder manually.
*** You can do this after installation but there are more steps outlined in Before You Install. Easier to do it before installation.
There are three methods to install Chocolatey,
Package Manager Console, and
Nuget.exe + PowerShell. I prefer the PowerShell installation option as it strikes me as the simplest, with the least moving parts to reach the end goal. If you do not agree, feel free to read the installation documentation to learn how to install using the other two methods. Before installing with PowerShell we need to validate our execution policy settings. Open PowerShell prompt, on Windows 7:
- Goto Start, put cursor in
Search Text Box
- Select Windows PowerShell
- At the prompt type the following command
- If the result is
Restrictedthen proceed to next step to change the policy to
Unrestricted. Otherwise, skip to
step 11to install Chocolatey.
- Open PowerShell as Administrator
- Run the command
- Close PowerShell
- Open PowerSheel normally
- Check execution policy again, run command
- To install Chocolatey run the command
iex ((new-object net.webclient).DownloadString(‘http://bit.ly/psChocInstall’))
- Open any command prompt, type the following command
Chocolatey /?to get command options There will be a bunch of jargon above, but at the bottom you will see the following starting with Usage …
Browse Chocolatey Gallery
There are several methods to browse the Chocolatey Gallery, using Chocolatey.org, command line, and Visual Studio Package Manager Console.
Browse Chocolatey Gallery via web
To browse the Chocolatey Gallery use Chocolatey.org. Once at the site, you can click the Packages link from the menu or type in a name in Search Packages.
Browse Chocolatey Gallery from command line
To browse the Chocolatey Gallery using the command line. Open a command prompt, type
chocolatey list searchName to get a list of packages matching
searchName. For instance, give me a list of all packages for NUnit, type
chocolatey list nunit ( will be in demo ). Below is a command line help.
From the command prompt you do other things like: Command Reference
- Get help
- Find the chocolatey version running
- Determine the lastes version of a package and what version is on local system
chocolatey version nunit
- Get a complete list of packages ( might take a while – DO NOT suggest it )
Browse Chocolatey Gallery using Package Manager Console for Visual Studio
To browse the Chocolatey Gallery using Package Manager Console within Visual Studio. Open VS IDE, in the file menu navigate to
Tools -> Library Package Manager -> Package Manager Console OR you can use
Ctrl+P, Ctrl+M. For more details on using Package Manager Console. Tip-Trick for Package Manager Console is tab completion for commands and intellisense. Type
Get-P in the Package Manager Console then press the
TAB key to complete the command, should see ‘Get-Package’. This can be done for the entire command below.
Get-Package -ListAvailable chocolatey
Installing First Application from Chocolatey Gallery
The first application to install,
warmuP, a template utility part of the Chuck Norris Project by Dru Sellars and Rob Reynolds. The third blog in the series,
Create and Publish First Chocolatey Nuget Package, will cover warmup configuration and use to create a NEW custom Chocolatey package. For now, simply install warmup.
Warmup allows you to define templates for entire projects and change them as technology changes and you learn new things. The templates are kept in source control. Both SVN and Git are supported places to keep your templates.
To install warmuP, run the following command
chocolatey install warmup at the command line. Like me, you may prefer a simpler method, run command
cinst warmup for brevity. Once installed, run command
Updating First Application
There are times where the simple thought of updating the tools used on a daily basis can be overwhelming and something I simply care not to attack ( nor do I have the time ). With Chocolatey the shear act of determining if an update is required boils down to a
few key stokes,
chocolatey update warmup. Now, if you are really lazy or just like to reduce typing ( I know you will like this ) use
cup warmup. Okay, not impressed with updating a single application, one at a time. Totally understand! I want to update ALL my tools Chocolatey manages at once too. The sweetness of Chocolatey continues to melt in your mouth. Simply do this
cup all. Can it get any simpler?
The Frozen Bytes Chocolatey Series continues with Grab Some Chocolatey Packages, covering installing a few interesting Chocolatey packages to simply development.