Open Source.NET

Chocolatey Goodness: A Sweet Installer

Chocolatey is a powerful installation program for open-source software.

If you've been around Linux, you've undoubtedly heard of apt-get or portage, and enjoyed their usefulness. For a great while, Windows users have had to deal without such a useful utility.

Wouldn't it be nice if you could just execute a command and have applications downloaded and installed without all the leg work? How awesome would it be to get a new rig up and going with the software you need just by executing a few commands? That time is finally here, powered by an easy-to-use tool: Chocolatey.

With the advent of package managers in the Microsoft stack, it was only a matter of time before something new came out leveraging them. RobReynolds and community have taken NuGet and built an application package manager around it to create Chocolatey.

To install Chocolatey, first download the bootstrap script and run it. The script requires that your PowerShell execution policy be set to Unrestricted. If you've this done already, you can execute the following:

iex  ((new-object  net.webclient).DownloadString(""))

Otherwise, run the PowerShell command window as an administrator and run the following:

$originalPolicy  Get-ExecutionPolicy
Set-ExecutionPolicy Unrestricted
iex ((new-object net.webclient).DownloadString(""))
Set-ExecutionPolicy $originalPolicy

Chocolatey provides new commands available from the command prompt. A key one is named cinst. This is what you'll use to install Chocolatey packages.

I haven't installed Console2 on this system yet, so let's get it done with the command line and cinst:

C:\> cinst  console2

The command produces the following ouput:

Chocolatey ( is installing console2
(from to "C:\NuGet\lib"
Package License Acceptance Terms
Please run chocolatey /? for full license acceptance verbage.
By installing you accept the license for the package you are installing...
Successfully installed 'Console2 2.0'.

Chocolatey Runner (CONSOLE2)
Chocolatey Installation (chocolateyinstall.ps1)
Looking for chocolateyinstall.ps1 in folder C:\NuGet\lib\Console2.2.0
If chocolateyInstall.ps1 is found, it will be run.
Running powershell -NoProfile -ExecutionPolicy unrestricted -Command "& import-module -nameĀ 
'C:\NuGet\chocolateyInstall\helpers\chocolateyInstaller.psm1'; &
This may take awhile and permissions may need to be elevated, depending on the package.
Executable Batch Links
Looking for executables in folder: C:\NuGet\lib\Console2.2.0
Adding batch files for any executables found to a location on PATH.
In other words, the executable will be available from ANY command line/powershell prompt.
Adding C:\NuGet\bin\Console.bat and pointing to C:\NuGet\lib\Console2.2.0\bin\Console.exe
Chocolatey has finished installing console2
C:\> console

[Click on image for larger view.]
Figure 1. The Console program's tabbed interface. It was downloaded using Chocolatey.

So in about one minute, with five seconds of effort, Console2 (Figure 1) has been installed. How many times have you had to download ASP.NET MVC3 on a dev box? Now you can just use cinst aspnetmvc. What about 7Zip, Notepad++, ILMerge, msysGit, Fiddler? They're all available. Browse the ChocolateyGallery to see what's available.

Chocolatey also allows you to install any package with an executable (consider these tools packages). Many of these are available on the feed, which Chocolatey automatically checks in addition to the gallery. So you can try something like StatLight, RavenDB and NHibernate Profiler (NHProf).

In addition to cinst (an alias for chocolatey install), there are a few other commands of note:

  • chocolatey. This displays full command syntax and suggestions
  • cinstm. This will install a package if it's missing locally
  • clist. This lists available packages
  • cup. This updates a package to the newest available version
  • cver. This shows the installed and latest available versions of a package

The cup and cver commands take a package name and source as parameters. The package defaults to Chocolatey if a package name isn't supplied, and uses the default feed.

A powerful function that Chocolatey brings is the ability to update every package on your system with one command. cup all will check all installed packages for updates and install them. Think of this like a Windows update, but for all your other applications.

Do you have or know of an application that would be an awesome addition to Chocolatey? Great! You can package the application and follow the packagecreation instructions in order to get the application integrated and submitted to the gallery. Let's get Chocolatey!


About the Author

Ian Davis is the Master Code Ninja for software architecture and development consulting firm IntelliTechture. A C# MVP, Davis is an expert on the .NET Tramework and co-organizer of the Spokane .NET User Group who frequently speaks at industry events. He spends most of his free time as an open source author and advocate, publishing and working on many open source projects.

comments powered by Disqus


  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot has been a boon for developers, but AI might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

  • What's New for Python, Java in Visual Studio Code

    Microsoft announced March 2024 updates to its Python and Java extensions for Visual Studio Code, the open source-based, cross-platform code editor that has repeatedly been named the No. 1 tool in major development surveys.

Subscribe on YouTube