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


  • How to Create a Machine Learning Decision Tree Classifier Using C#

    After earlier explaining how to compute disorder and split data in his exploration of machine learning decision tree classifiers, resident data scientist Dr. James McCaffrey of Microsoft Research now shows how to use the splitting and disorder code to create a working decision tree classifier.

  • Microsoft: Move from Traditional ASP.NET to 'Core' Requires 'Heavy Lifting'

    There are plenty of reasons to move traditional ASP.NET web apps -- part of the old .NET Framework -- to the new cross-platform direction, ASP.NET Core, but beware it will require some "heavy lifting," Microsoft says.

  • Purple Blue Nebula Graphic

    How to Compute Disorder for Machine Learning Decision Trees Using C#

    Using a decision tree classifier from a machine learning library is often awkward because it usually must be customized and library decision trees have many complex supporting functions, says resident data scientist Dr. James McCaffrey, so when he needs a decision tree classifier, he always creates one from scratch. Here's how.

  • Blazor's Future: gRPC Is Key

    Blazor guru Steve Sanderson detailed what Microsoft is thinking about the future of the revolutionary project that enables .NET-based web development using C# instead of JavaScript, explaining how gRPC is key, along with a new way of testing and a scheme for installable desktop apps.

  • Don't Do It All Yourself: Exploiting gRPC Well Known Types in .NET Core

    If you're creating business services that send dates and decimal data then you may be concerned that gRPC services don't support the relevant data types. Don't Panic! There are solutions. Here's how to use them.

.NET Insight

Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.

Upcoming Events