Apt Windows: Let’s Get Chocolatey!

Chocolatey is a global automation tool that makes use of the NuGet package management system. It is an advanced packaging tool that makes use of PowerShell to allow you to do virtually anything on a system. The main use of Chocolatey is to install applications and tools silently on your machine. This makes it a machine package manager with a Windows flavour.

Chocolatey!

Story Time

Let’s start with a story. Two guys, Bob and Richard, need to get their computers ready to do some development work with Git. Neither Bob nor Richard have worked with Git before. This is a story about the process they each go through to get Git.

Richard goes off to research. After a while he learns the tool he wants to install for Windows is mSysGit. He searches, downloads the latest version and goes to install it. He realizes he downloaded the wrong one and starts over. He may not have his settings set up properly. So then he spends time trying to figure out what his settings should be. After a process of maybe a whole morning, he finally has Git installed and hopes he is set up properly. And Richard only knows about mSysGit and not any other tools that may have helped him with using Git.

Bob has recently installed this neat tool called Chocolatey. He heads out to chocolatey.org and searches for Git. He learns that there are several cool tools for working with Git on Windows. He decides that he wants to use Git Extensions for helping him visualize some of the Git work. He opens a command line, types cinst gitextensions and hits Enter. Git Extensions has a dependency on mSysGit, so Chocolatey downloads and installs it silently on his machine. It configures Git for proper Windows usage. Then Chocolatey downloads and silently installs Git Extensions on his machine. In less than ten minutes Bob is ready to go and has some of the best tools for working with Git available to him.

Did Bob get lucky? No. It’s just that Bob didn’t have to really make that many decisions. He decided he wanted a tool. Then Chocolatey did all of the work, made all of the decisions, got the dependent applications, and even configured his machine properly. He has little left to do to finish setting up the machine for access to GitHub.

You may have had similar experiences with other tools. The moral of the story? Richard took over 3 hours to get somewhat up to speed. Bob came fully up to speed in less than ten minutes. Don’t be a Richard.

What is Chocolatey?

What do you get when you mix the ideas of apt-get, Windows, PowerShell and NuGet together? You get a pretty chocolatey creation. And that’s just what Chocolatey is - a global silent application installer, a tools enabler. It configures packages. It quietly and effortlessly installs & updates applications/tools while you focus on other things. It’s like Windows Update for the rest of the stuff you have installed on your machine.

Chocolatey is a machine package manager that is kind of like apt-get with a Windows flavour. If you are unfamiliar with apt (Advanced Package Tool), it is the concept of software, configuration, components, everything (including the Linux kernel in Debian), built into packages that you can install on a Linux machine. Apt handles retrieval, configuration, installation and updating of software packages.

Let’s walk through aspects of Chocolatey and how it can shift your thinking about what’s possible with Windows.

Install Chocolatey

Chocolatey itself has a one line install. The requirements are that you have at least PowerShell 2.0 and .NET Framework 4.0 installed. Then you open a PowerShell prompt, type Get-ExecutionPolicy. If it is set to Unrestricted you can install Chocolatey, otherwise you need to change that by running PowerShell as an Administrator.

If you are good to go, issue this command:

iex ((new-object net.webclient).DownloadString(‘http://bit.ly/psChocInstall’))

Pretty painless, right? Let’s try to install something.

Install An Application

Try this now. Let’s install a popular Notepad replacement known as Notepad++. If you already have it installed, this command will likely update it to the latest version. Open a command line (not a powershell) window and type:

c:\> chocolatey install notepadplusplus
OR c:\> cinst notepadplusplus

Notice how it does all of the work for you. It downloads the application and installs it on your machine silently. You just wait for Chocolatey to finish and give you the good news. You can also head over to http://chocolatey.org and choose a package to install from there.

Update Your Applications

Many of us get all of these tools/applications installed on our system, but unless the tool has a bug or it has some sort of notifications for updates, we typically have no idea when there is an update for that tool/application. Chocolatey can help with that in one of two ways.

To update a package, you can type

c:\> chocolatey update somePackageName
OR c:\> cup somePackageName

Updating one package at a time in itself is not that awesome. What would be better is to update them all with one command. So type:

c:\> cup all

Awesome! You just updated every package you have installed that has an update. That’s like windows update, but for everything else!

Stay Tuned…

Have you ever heard the phrase that we sometimes find things that solve a pain that we may not realize that we had? Chocolatey speeds up your time to getting tools / applications to your machines.

In the next segment on Chocolatey, we will talk about setting up packages and how easy that is. We will also look at setting up a development machine environment from source control using Chocolatey and PowerShell.

Let’s Get Chocolatey!

You might also like...

Comments

About the author

Rob Reynolds

Rob Reynolds United States

Rob Reynolds has been programming in .NET since the early days of 1.0. In his day job he drinks beer and tries to get creative at a digital marketing agency. Rob is a C# MVP, ASPInsider, C# Insi...

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Memory is like an orgasm. It's a lot better if you don't have to fake it.” - Seymour Cray