Configuring a Chocolatey Install

category: [ Powershell ] tags: [ Chocolatey ] [ DotNet Pretty ] [ MyGet ]
created: 28 Oct 2014 @ 06:26 modified: 24 Apr 2017 @ 13:57

So yesterday I posted Pushing a new project to Chocolatey and I said I would create another post showing how to configure how the Chocolatey install runs and this is that post Smile with tongue out.


The first (only really) step to do this is creating a ChocolateyInstall.ps1 script. From looking at other packages I saw that there was a file like this in a tools folder so I created one for myself in my DotNet Pretty project


and set the Build Action to Content and Copy to Output Directory to Copy Always


The contents of the script was as below

[string]$ScriptDir = Split-Path $MyInvocation.MyCommand.Path -Parent
[string]$copyTo = "$([System.Environment]::GetFolderPath("mydocuments"))\Visual Studio 2013\Visualizers"
[string]$mainAssemblyPath = "$ScriptDir\..\..\lib\net45\*.*"
[string]$binDependenciesAssemblyPath = "$ScriptDir\..\binDependencies\*.*"
if (!(Test-Path -LiteralPath $copyTo))
New-Item -Path $copyTo -ItemType directory
Copy-Item -Path "$mainAssemblyPath" -Destination "$copyTo" -Force
Copy-Item -Path "$binDependenciesAssemblyPath" -Destination "$copyTo" -Force

Basically doing the exact same thing as what I was doing with the DEBUG post build event in the project settings

I checked that in (over a couple of commits because I didn't get it right the first time Smile with tongue out). MyGet picked up the new commit and performed a build for me. Instead of waiting for my hourly push of packages to Chocolatey from MyGet I just pushed the package as I did in the previous post. I then ran the Chocolatey install for my package

choco install dotnetpretty -pre

and then navigated to the Visualizers folder and my new assemblies were there Smile


If you have any feedback or a better way to perform this install do let me know Open-mouthed smile


Gordon Beeming works at Nologo Studios in the sunny city of Durban, South Africa. He is the Lead for the Data and Services Team and has a strong focus on Developer Efficiencies and R&D. When he's not hacking away at a keyboard in Visual Studio he'll generally be relaxing with his family or hitting the black top getting in some mileage. He is a Visual Studio ALM Ranger and Visual Studio ALM MVP.

Follow me on Strava


I plan on writing a bunch of online tools and sharing the code for how I made those tools. If you have any feedback you can ping me on Twitter (@GordonBeeming) or mail me online-tools[email protected].