This year, it feels like I've spent a lot of my time helping clients automate their deployment processes. Cloud servers are definitely gaining traction nowadays. Umbraco, as a service has been out for a while, Episerver is strongly focusing on DXC, their cloud offering and Azure are bringing out some really cool powerful tools that I think are going to become common practice in a few years.

When we work with cloud servers, we want to be able to install and update everything automatically. It is very common to have a 'Build Environment' build step and a 'Deploy' build step. One of my favorite tools is Chocolatey the package manager for Windows. If you've never come across Chocolatey, it does the same thing as Nuget does for coders. It installs software programs through a command prompt. Chocolatey has thousands of packages for most of your favorite software programs.

Chocolatey is not only useful for build servers, you can also use it to install software on your own PC. As a contractor and someone who needs to set-up development environments regularly, being able to automate the set-up process now saves me days' worth of wasted time every year. If you work as a manager of other developers, just think how much time your team can save by simply automating this stuff. A recent client brought new laptops for the team (10-12 people) halfway through the project.

The process of each developer setting up their environment took a week's worth of combined effort but if we had run a Chocolate script we would have easily claimed two weeks' of time back into the sprint just by automating it all. If you're like me, who's been using PC's for years, then setting up environments is an extremely boring and tedious process now.

How To Get Started With Chocolately

You will primarily work with Chocolately with Powershell. I store several scripts in the same folder in my dropbox, this means that when I want to set-up a new environment, I open a normal command prompt, navigate to the folder, run a setup batch file and everything installs itself automatically. The install script, called 'configureiis.ps1' looks like this:

By default, Windows is configured to prevent Powershell scripts running, so we enable the script, download and install Chocolately and add it to the environment list. I use a script, called 'installApps.ps1' to install IIS automatically and enable all the features I need:

Next is where I use Chocolatey to install all the programs in a file called 'configureWindows.ps1'.  The '-Y' parameter at the end means Chocolatey won't prompt you to confirm the installation automatically:

You'll obviously want to configure this to suit your needs.  To browse for packages, go here.  Lastly, I call a script to set any configuration I care about.  At the minute, this script sets Chrome as my default browser.

That's it!  If you add all of those files into a folder and then in an Administrator open Command Prompt rn the setup.bat.  IIS will be configured and applications will be installed within 15 minutes.  That's a lot quicker than the several hours it used to take before!

Chocolatey Take Away

I'm hoping after reading this you can see the possibilities of using Chocolatey. It's pretty simple to install and start using and it has a ton of packages available now for you to install. It's not just built servers that you should think about automating, your developer environments, or even you own home PC can all be automated easily.