← all posts

Pushing a new project to Chocolatey

Gordon Beeming
Gordon Beeming
On this page8 sections ▾

#

#Inspiration

Today my DotNet Pretty articles were featured on @coding4fun by Greg Duncan and one of the comments by Niner bc3tech (@bc3tech) requested that I share this solution on Chocolatey. I decided that this was a good idea and decided to share my experience 🙂.

#Creating a Chocolatey Account

Creating the Chocolatey account was as simple as filling a couple of common fields at https://chocolatey.org/account/Register.

Chocolatey Registration Page
Chocolatey account registration page

In the registration mail you are given a link to Rules to be observed before publishing packages which mentions that you can host your packages with MyGet

Chocolatey Wiki - Hosting Packages on MyGet
Chocolatey Wiki page about hosting packages on MyGet

#Creating a MyGet Account

Heading over to MyGet I saw that they had a Free subscription

MyGet Pricing Page
MyGet pricing page showing the Free subscription tier

But they also have an offer for MVP's, ASPInsiders, Windows Azure Insiders and ALM Rangers 🙂. Fitting into 2 of these categories now I decided to head over to https://www.myget.org/mvp and request a NFR license 😁. The extra features available on this subscription made it perfect for my community project (and ones to follow 🙂). In no time I had my DotNet Pretty Package Feed up.

#MyGet Build Services

The DotNet Pretty project is currently hosted out on GitHub and so I decided that I'll try out MyGet's build services which is now in preview. This was as simple as clicking on BUILD SERVICES from the menu and then on Add build sources and then from GitHub.

MyGet Build Services - Add build source from GitHub
MyGet Build Services page with option to add build source from GitHub

this poped open the Link build source dialog where I selected the DotNet Pretty project from the list and clicked Add.

MyGet Link build source dialog
MyGet Link build source dialog for selecting GitHub repository

From here I clicked Build and in no time the build completed

MyGet Build Log
MyGet build log showing successful build completion

MyGet Package Feed
MyGet package feed showing the newly built DotNet Pretty package
and I had a package hosted in MyGet

MyGet Package Details
MyGet package details page for the DotNet Pretty package

#Updating GitHub project to show MyGet build status

From the build services page I was able to click on copy markdown

MyGet Build Services - Copy Markdown for Build Status Badge
MyGet Build Services page with option to copy Markdown for build status badge

which gave me the markdown that I could insert into the readme.md file which I did with my new favorite Markdown editor MarkdownPad 2

MarkdownPad editor showing readme.md with MyGet build status badge
MarkdownPad editor showing the readme.md file with the MyGet build status badge added

A quick commit added this status to the public project on GitHub

GitHub project page with MyGet build status badge
GitHub project page for DotNet Pretty showing the MyGet build status badge

#Pushing the packaged to Chocolatey

The next thing I needed to do was add a new package source to my MyGet package feed Chocolatey. I went over to the Package Sources menu and clicked on Add package source and the NuGet feed.

MyGet Package Sources - Add NuGet feed
MyGet Package Sources page with option to add a NuGet feed

The next bit was very simple, I simple clicked on Presets and then Chocolatey

MyGet Add Package Source - Presets for Chocolatey
MyGet Add Package Source dialog with Presets option for Chocolatey

This then went ahead and filled in the Name and Source for me

MyGet Add Package Source - Chocolatey preset applied
MyGet Add Package Source dialog with Chocolatey preset applied, showing Name and Source fields filled

All that was left to do was provide my Chocolatey which was my Username, Password and API Key. I also filled in some of the extra meta data for my source

MyGet Add Package Source - Chocolatey credentials and metadata
MyGet Add Package Source dialog with Chocolatey credentials and metadata filled in

Next I headed over to build services again and clicked on Push upstream

MyGet Build Services - Push upstream
MyGet Build Services page with Push upstream option

this presented a window like below

MyGet Push Package dialog
MyGet Push Package dialog for pushing to Chocolatey

where I just clicked on Push

MyGet Push Package confirmation
MyGet Push Package confirmation message after pushing to Chocolatey

And received the message saying they on it 😁. Headed back over to Chocolatey and my package was in the list

DotNet Pretty package on Chocolatey
DotNet Pretty package listed on the Chocolatey website

#Installing Chocolatey "Client"

On the machine I'm using I didn't have Chocolatey installed so opened up a PowerShell Command Window as Administrator (just for in case 🙂) and ran the command

iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))

#Installing my package

To test if my package was installer I ran the command below

choco install DotNetPretty -Pre

which confirmed that my package now now been installed

Package Installation Confirmation
Package installation confirmation message

At this point my Chocolatey package "installs" by dropping the package contents in the Chocolatey folder

Chocolatey Package Installation
Chocolatey package installation process
Chocolatey Package Installation (contd.)
Continuation of the Chocolatey package installation process

In a later post I will share how to configure the installation logic for a Chocolatey script.

Update: The post can be found here (Configuring a Chocolatey Install).

Gordon Beeming
Gordon Beeming

Father • Husband • Triathlete • SSW Solution Architect

Related posts