Creating software packages with Chocolatey Business

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.

PS C:Demo> dir
    Directory: C:Demo
Mode                LastWriteTime         Length Name
—-                ————-         —— —-
-a—-        3/17/2017   2:57 PM        2982992 npp.7.3.3.Installer.exe

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.

PS C:Demo> choco new –file=’npp.7.3.3.Installer.exe’ –build-package
Chocolatey v0.10.3 Business
Creating a new package specification at C:Demonpp.Installer
Generating package from custom template at ‘C:ProgramDatachocolateytemplatesNewFileInstaller’.
Generating template to a file
 at ‘C:Demonpp.Installernpp.installer.nuspec’
Generating template to a file
 at ‘C:Demonpp.Installertoolschocolateyinstall.ps1’
Successfully generated npp.Installer package specification files
 at ‘C:Demonpp.Installer’
Attempting to build package from ‘npp.Installer.nuspec’.
Successfully created package ‘C:Demonpp.Installernpp.installer.7.3.3.nupkg’

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.

PS C:Demo> choco install notepadplusplus –source=.notepadplusplus -y
Chocolatey v0.10.3 Business
Installing the following packages:
By installing you accept licenses for the packages.
notepadplusplus v7.3.3
notepadplusplus package files install completed. Performing other installation steps.
Installing npp.7.3.3.Installer.exe…
npp.7.3.3.Installer.exe has been installed.
 The install of notepadplusplus was successful.
  Software install location not explicitly set, could be in package or
  default install location if installer.
Chocolatey installed 1/1 packages. 0 packages failed.
 See the log for details (C:ProgramDatachocolateylogschocolatey.log).

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
To give Chocolatey a try or to learn about additional features check out


Leave a Reply

Your email address will not be published. Required fields are marked *