Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / All-Topics

Configuring a Chocolatey Install

5.00/5 (1 vote)
21 Nov 2014CPOL1 min read 5.9K  
Configuring a chocolatey install

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.

ChocolateyInstall.ps1

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.

2014-10-28_08-18-26

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

2014-10-28_08-18-52

The contents of the script were 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

2014-10-28_08-24-11 

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

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)