How Chocolatey saves me time

Reading Time: 6 minutes

I want to share an application I use when setting up a new machine or recovering from a re-install of Windows, called Chocolatey.

Since I started using Chocolatey, I find a 50/50 split of people I talk to that have actually heard of it. Until very recently I fell into the “I have no idea what you are talking about but I’ll nod knowingly” bucket.


My co-speaker and friend, Paul Broadwith (b|t) is a long time contributor to the Chocolatey community. He introduced me to it shortly before he started working with them last year and I was blown away by how easy to use it was and the time it saved me.

So, what is Chocolatey then?

In my own words, it’s the quickest way to get a machine up and running, ready to start working. Chocolatey is a package manager for Windows that allows you to script out the installation of (what feels like) almost anything. I was able to get up and running on a new laptop in just a few hours, while I worked on something else. Forget constant Next > Next > Next installation wizards. I had all the tools I needed to do my job, not just apps but PowerShell modules too, all installed automatically.

How do I use it then?

It’s pretty simple to get started and I know I’m not using it to it’s full potential but here’s how I use it:

  • Have a look on the Chocolatey site for fantastic Installation instructions. I installed using PowerShell with the following command from an elevated prompt:
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString(''))
  • Once installed, you can run commands to install any of the packages listed on the Chocolatey community repository. Paul showed me how to create my own package so I could list out all of the apps that I wanted then all I have to do is execute the package. Start by creating a package in the directory of your choice:
choco new NameofmyPackage
  • This creates a a folder structure and files used for actually publishing a package but I just want to use this to manage my own machine and apps so I don’t need to worry about all the other components.

You can delete these but you’ll also need to comment or remove the reference to the tools folder in the nuspec file:

<file src="tools\**" target="tools" />

Now we need to open that file and add some minimal required info to use it and we can get started listing out all the apps I use. You can get a comprehensive list of the required components from Microsoft’s nuspec reference.

Now we need to open up the nuspec file and make the required edits:





We need to set the version so that the file will package up correctly. As this is for our own use we can set this to anything.

The title will already be set but you can change that if you wish. I’ll set mine to “Craig’s Choco package”. We finally need to un-comment the dependencies section. This is where we’ll add all of our apps using the names on There is code their to define versions but I’m happy to grab the latest version of all my apps so I’ll discard those parts. Here’s an example:

  <dependency id="firefox" />
  <dependency id="googlechrome" />
  <dependency id="powershell" />
  <dependency id="pester" />
  <dependency id="visualstudiocode" />
  <dependency id="sql-server-management-studio" />
  <dependency id="git" />      
  <dependency id="visualstudio2017enterprise" />
  <dependency id="ssdt17" />
  <dependency id="logitech-presentation" />


After you’ve made those edits your nuspec file should look like this, with a lot of commented out code:

<?xml version="1.0" encoding="utf-8"?>
<!-- Read this before creating packages: -->
<!-- It is especially important to read the above link to understand additional requirements when publishing packages to the community feed aka dot org ( -->

<!-- Test your packages in a test environment: -->

This is a nuspec. It mostly adheres to Chocolatey uses a special version of NuGet.Core that allows us to do more than was initially possible. As such there are certain things to be aware of:

* the package xmlns schema url may cause issues with nuget.exe
* Any of the following elements can ONLY be used by choco tools - projectSourceUrl, docsUrl, mailingListUrl, bugTrackerUrl, packageSourceUrl, provides, conflicts, replaces 
* nuget.exe can still install packages with those elements but they are ignored. Any authoring tools or commands will error on those elements 

<!-- You can embed software files directly into packages, as long as you are not bound by distribution rights. -->
<!-- * If you are an organization making private packages, you probably have no issues here -->
<!-- * If you are releasing to the community feed, you need to consider distribution rights. -->
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
<package xmlns="">
    <!-- This section is about this package, although id and version have ties back to the software -->
    <!-- id is lowercase and if you want a good separator for words, use '-', not '.'. Dots are only acceptable as suffixes for certain types of packages, e.g. .install, .portable, .extension, .template -->
    <!-- If the software is cross-platform, attempt to use the same id as the debian/rpm package(s) if possible. -->
    <!-- version should MATCH as closely as possible with the underlying software -->
    <!-- Is the version a prerelease of a version? -->
    <!-- Note that unstable versions like 0.0.1 can be considered a released version, but it's possible that one can release a 0.0.1-beta before you release a 0.0.1 version. If the version number is final, that is considered a released version and not a prerelease. -->
    <!-- <packageSourceUrl>Where is this Chocolatey package located (think GitHub)? packageSourceUrl is highly recommended for the community feed</packageSourceUrl>-->
    <!-- owners is a poor name for maintainers of the package. It sticks around by this name for compatibility reasons. It basically means you. -->
    <!-- ============================== -->

    <!-- This section is about the software itself -->
    <title>Craigs Choco Package</title>
    <!-- projectUrl is required for the community feed -->
    <!-- <copyright>Year Software Vendor</copyright> -->
    <!-- If there is a license Url available, it is required for the community feed -->
    <!-- <licenseUrl>Software License Location __REMOVE_OR_FILL_OUT__</licenseUrl>
    <!--<projectSourceUrl>Software Source Location - is the software FOSS somewhere? Link to it with this</projectSourceUrl>-->
    <!--<docsUrl>At what url are the software docs located?</docsUrl>-->
    <tags>demopackage SPACE_SEPARATED</tags>
    <description>__REPLACE__MarkDown_Okay </description>
    <!-- <releaseNotes>__REPLACE_OR_REMOVE__MarkDown_Okay</releaseNotes> -->
    <!-- =============================== -->      

    <!-- Specifying dependencies and version ranges? -->
      <dependency id="firefox" />
      <dependency id="googlechrome" />
      <dependency id="powershell" />
      <dependency id="pester" />
      <dependency id="visualstudiocode" />
      <dependency id="sql-server-management-studio" />
      <dependency id="git" />
      <dependency id="visualstudio2017enterprise" />
      <dependency id="ssdt17" />
      <dependency id="logitech-presentation" />
    <!-- chocolatey-core.extension -
         - You want to use Get-UninstallRegistryKey on less than 0.9.10 (in chocolateyUninstall.ps1)
         - You want to use Get-PackageParameters and on less than 0.11.0
         - You want to take advantage of other functions in the core community maintainer's team extension package

    <!--<provides>NOT YET IMPLEMENTED</provides>-->
    <!--<conflicts>NOT YET IMPLEMENTED</conflicts>-->
    <!--<replaces>NOT YET IMPLEMENTED</replaces>-->
    <!-- this section controls what actually gets packaged into the Chocolatey package -->
    <!-- <file src="tools\**" target="tools" /> -->
    <!--Building from Linux? You may need this instead: <file src="tools/**" target="tools" />-->


The last thing we need to do before we can use it is to package it up by running:

Choco pack

This created the NUPKG file in the same folder as your nuspec file. You’ll need to increment the version number and re-run this command everytime you add or remove dependencies (apps you want to install).

The easy bit

To Install all these lovely apps, with no effort at all simply run the following command:

Choco install <packagename> -s ".;chocolatey"

Or in our case this would be:

Choco install demopackage -s ".;chocolatey"

To break this command down a little, the -s flag will try to find the app in the local directory first, then go to Chocolatey to get it if it’s not found or up to date. That means, you can just run this package regularly and not have to worry about it re-installing already up-to-date apps. It’s so simple and robust that I mourn all the hours I’ve spent searching, downloading and clicking through wizards all these years!

It’s worth noting at this point that if you remove one of those apps from your dependency list, it won’t uninstall the app next time you run the package, it’s just going to ignore it.

Now, this isn’t the only way to install apps using Chocolatey but it’s the way I found the easiest. I could fire it off and go do something else. More info can be found on Chocolatey’s Install command help page. I hope this saves others as much time as it’s saved me.



Photo by Monique Carrati on Unsplash

You may also like...

Leave a Reply