Skip to content

Instantly share code, notes, and snippets.

@indented-automation
Last active July 21, 2022 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indented-automation/04badb79a8ca5268fc560e7b9da45211 to your computer and use it in GitHub Desktop.
Save indented-automation/04badb79a8ca5268fc560e7b9da45211 to your computer and use it in GitHub Desktop.
Choco sample
# Chocolatey must be installed on all nodes which intend to use it
https://chocolatey.org/install#individual
# Make a folder called DhcpDaemon
New-Item DhcpDaemon -ItemType Directory
# Inside that folder, make a folder called Tools
# This will hold your installation files and an install script
New-Item DhcpDaemon\tools -ItemType Directory
# Make an install script
New-Item DhcpDaemon\tools\chocolateyInstall.ps1
# Open this script in your favourite editor
notepad DhcpDaemon\tools\chocolateyInstall.ps1
# The content of the script will look something like this:
$packageParams = @{
PackageName = 'DhcpDaemon'
FileType = 'exe'
SoftwareName = 'DhcpDaemon'
File = Join-Path -Path $PSScriptRoot -ChildPath DhcpDaemonInstaller.exe
SilentArgs = ''
ValidExitCodes = 0
}
Install-ChocolateyInstallPackage @packageParams
# Each package needs a nuspec file, an XML file. The nuspec file is for metadata, package name, versions, etc, etc
New-Item DhcpDaemon\dhcpdaemon.nuspec
# Open this XML file in your favourite editor.
notepad DhcpDaemon\dhcpdaemon.nuspec
# The content of the XML file would be similar to this. Remember to fix package names and version numbers.
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<version>1.0.0.0</version>
<title>dhcpdaemon</title>
<authors>You</authors>
<copyright>YourOrg 2022</copyright>
<id>dhcpdaemon</id>
<summary>DhcpDaemon installer</summary>
<description>Some description for this package</description>
</metadata>
</package>
# At this point the package can be created
choco pack DhcpDaemon\DhcpDaemon.nuspec
# This step creates a nupkg file with a version number embedded in it.
# It is possible to create chocolatey repositories on file shares, or just install the package from a folder:
choco install dhcpdaemon --source c:\folder\containing\nupkg\file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment