At a few of the organizations I worked for we had a network share specifically for software. We would dump any software installation media that we used and place it there to be used when necessary. Sound familiar? There are a lot of software deployment solutions now that can help manage software packaging and deployment, but perhaps none better for Windows administrators than Chocolatey.
Chocolatey is one of the most used package management tools used by Windows administrators and for good reason. While open source is a completely command line based package manager, Chocolatey for Business (C4B) is moving towards complete software management and has both CLI and GUI options to address varying skill sets and preferences in the enterprise. Perhaps best of all it integrates well with configuration management tools such as Puppet, Chef, Ansible and SCCM. Chocolatey is built on top of the NuGet packaging technology created by Microsoft, which is also used by public repositories sites such as PSGallery. Even without a configuration management solution, Chocolatey can be used with an internal repository and deployed with other tools, such as PowerShell.
Today, we will go over how to create a Chocolatey package with the Business version of Chocolatey from an installer file. By using the command “choco new” we can quickly create a Chocolatey package that will be ready for distribution.
For this example I have an installer for Notepad++ that I downloaded and placed into the folder C:Demo. I will use this installer to create our Chocolatey package.
First lets run the command choco new notepadplusplus –file=’npp.7.3.3.Installer.exe’ –build-package. Using this command we are telling Chocolatey to create a package with the name “Notepadplusplus” from the installer file npp.7.3.3.Installer.exe. Note that this command can be run without including the name “notepadplusplus” but it will result in Chocolatey creating a name which is not always what is preferred.
The notepadplusplus.nuspec file is an XML file that contains metadata about the package such as name and version. You will notice that Chocolatey was able to pull the version information from the installer file, which is very handy; however, additionally, you can specify the version as well with the –version parameter. Keeping the correct version of the package is important as it uses this information to upgrade packages if a new version is available in a repository with the choco upgrade command. The most important file created, though, is the notepadplusplus.nupkg file, which is all that is needed now to in order to install Notepad++ with Chocolatey.
We can now try to install it on our local machine to ensure the package installs correctly.
We will run the command choco install notepadplusplus –source=.notepadplusplus -y. It is important to point our source to the folder that contains our NuGet package for this test, otherwise it will attempt to install from our default repository.
Success! The Notepad++ package installed successfully. Now we can deploy it from our internal repository to machines in the environment.
So to summarize:
- Downloaded installation file
- Used “choco new” to create the NuGet specifications and NuGet package
- Used “choco install” to install the package locally