Things chocolate is good for:
- eating chocolate – the darker the better
- chocolate fondue
- chocolate brownies
- triple choco cookies
- installing software
The last one isn’ quite right – but, no matter how sweet chocolate is, chocolatey might be even more delicious!
Ok, clarification: Chocolatey (short: “choco”) is a package manger for Windows that actually works really well, has loads of packages in the public repo – and you can create packages yourself pretty easily!
– if you are not hyped right now – you may as well leave 🙂 –
In 2011, RealDimensions Software LLC. (you may as well say “Rob Reynolds”) started developing a package manager based on NuGet. In November 2016, Chocolatey Software, Inc. was formed as as spinoff of RealDimensions Software. Currently, the community repository of Chocolatey features more than 4500 packages, receiving approx. 1 download/second!
Chocolatey comes in four different flavors: “open source”, “Pro”, “MSP”, “Business” – not judgding, Rob should have called them “Vanilla”, “Choco Chip”, “Choco Muffin” and “Triple-Choco-Chip-Explosion”. (see https://chocolatey.org/pricing)
Not going to tell you which version is best for you – just saying the free OSS version is sufficient for most of everyone’s daily activities concerning installing and updating software, the business (‘biz’) edition rocks your workplace! (more on this later on…)
You can use Chocolatey as you’d use any other “classic” package manager on a Linux system – by typing
in your command prompt.
If you’re not keen on using a terminal, you can use the, still-in-progress – but ready-for-everyday-usage ChocolateyGUI. (Version 0.15 is soon to be release, and there will be some HUGE improvements over the 0.13.x version!)
Pretty straight forward: follow the instructions on https://chocolatey.org/install
Why would I use it?
Using a very old and bad analogy: time is money, money is time, choco saves you time, so choco saves you money!
Using Chocolatey at work (yup, I’ve been the one that has been assigned with setting up a Chocolatey environment :-)) – I soon started to realize that keeping packages up-to-date is a never-ending time-consuming task. Being a software dev, I soon wanted to automate the process of pulling in packages from the community repo and putting them onto our internal server. (most companies won’t be happy with directly accessing executables from a public feed – you’ll want to have them at a secure location and be virus and malware-checked on a regular basis. ProTip: use ProGet for hosting a Chocolatey server. (Free and Commercial options available!))
Asking around on how to best implement such a feature, I came across the gitter-channel of Chocolatey. Fun fact: due to the time zones the choco-devs are living in there’s basically always one of the core-devs available for Q/A!
If you get the biz license, there’s a feature called ‘internalizing’ which downloads and recompiles a package so you can put it onto an internal server straight away! – Create a Jenkins job with a little PowerShell magic behind it and BOOM: time saved!
So now, I just enter the name of a package I want to internalize and hit enter. The downloaded package(s – yes dependencies included) will be virus checked, binaries put on a local unc-share and the recompiled nupkg put onto the local Chocolatey server.
Checking ProGet, we currently have 338 packages with more than 3000 downloads on our server that I set up in December, what a hassle – and how time-consuming – this would have been without the internalize feature!
This is how a Jenkins job (the PowerShell “magic”) could look like for such a “internalize job”:
$package = $env:PACKAGE_ID $targetserver = $env:INTERNAL_SERVER $apikey = $env:API_KEY_OF_INTERNAL_SERVER $uncshare = $env:INTERNAL_UNC_SHARE choco download --recompile $pkg --resources-location="$uncshare\$pkg" -source="$sourceStream" --force $genpkg = ((gci *.nupkg -recurse).FullName | Select-String -Pattern $pkg) choco push $genpkg -source="$targetserver" -api-key="$apikey" -Verbose -Force
Matt Wrock was kind enough to give us Boxstarter. It adds the missing pieces to Chocolatey!
You want to install software with choco? – no prob.
You want to set-up a dev machine or a buildserver, installing dozens of packages in a row, automatically restarting the machine whenever necessary and continue installing afterwards? – that’s where Boxstarter fits in!
You want to install all available Windows updates, add tray icons after installing choco packages, change windows explorer options, in other words: customize a windows environment? – that’s where Boxstarter fits in!
An example Boxstarter use to set various Windows options, install Firefox, Visual Studio Community, Visual Studio Code, NotepadPlusPlus and also install security relevant Windows updates:
# Boxstarter options $Boxstarter.RebootOk=$true # Allow reboots? $Boxstarter.NoPassword=$false # Is this a machine with no login password? $Boxstarter.AutoLogin=$true # Save my password securely and auto-login after a reboot Update-ExecutionPolicy RemoteSigned Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions Enable-RemoteDesktop Disable-BingSearch Enable-PSRemoting -Force choco install firefox -y choco install visualstudiocommunity2013 -y choco install VisualStudioCode -y choco install notepadplusplus -y Install-WindowsUpdate
Just for your notice: Chocolatey can be build and run with mono. I’m still fiddling with PowerShell on Linux to get everything working as I’d like it to – but there is no reason it _cannot_ work, and I’ll put up another post as soon as I’ve got some working samples to put on GitHub 🙂
Currently I’m focusing a lot on Chocolatey and trying to find the perfect place for this tool – both – at work (Windows) as well as at home (Linux). I’ve just started to grasp what this tool is able to do and may be able to do in the future, so I hope more posts with how-to’s, scripts and small tools (GitHub), and my experience (and experiments! :-)) will show up on this blog!
For now, I’ve started to put up some scripts I use: https://github.com/mwallner/SoftwareAutomation – they basically work but need some extra maintenance.