DEV Community

Cover image for Publish a simple executable from Rust on Chocolatey ๐Ÿซ
Thomas Gotwig
Thomas Gotwig

Posted on • Edited on

Publish a simple executable from Rust on Chocolatey ๐Ÿซ

The most comfortable way to install software on Windows is thorugh Chocolatey ๐Ÿซ And in this guide you will learn how to do that! ๐Ÿคฉ At least for simple executables ๐Ÿฃ

I successfully published my Rust app vidmerger in that way! ๐ŸŽžโœจ

๐Ÿฃ Initializing

First of all install the cli-tool for Chocolatey:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Enter fullscreen mode Exit fullscreen mode

Then run choco new my-app to generate a folder called my-app with the following content:

my-app
โ”œโ”€โ”€ ReadMe.md
โ”œโ”€โ”€ _TODO.txt
โ”œโ”€โ”€ my-app.nuspec
โ””โ”€โ”€ tools
    โ”œโ”€โ”€ LICENSE.txt
    โ”œโ”€โ”€ VERIFICATION.txt
    โ”œโ”€โ”€ chocolateybeforemodify.ps1
    โ”œโ”€โ”€ chocolateyinstall.ps1
    โ””โ”€โ”€ chocolateyuninstall.ps1
Enter fullscreen mode Exit fullscreen mode

The minimal setup for publishing would look like:

my-app
โ”œโ”€โ”€ my-app.nuspec
โ””โ”€โ”€ tools
    โ”œโ”€โ”€ LICENSE.txt
    โ””โ”€โ”€ VERIFICATION.txt
Enter fullscreen mode Exit fullscreen mode

The *.ps1 files are basically for defining shell commands which run on beforemodify, install and uninstall. We don't really need them for publishing a simple executable.

Put your *.exe file from Rust or whatever into the tools folder ๐Ÿฆ€

โš™๏ธ Modifying

I think I'll just show you here my three modified files from my Rust app vidmerger, modify them accordingly ๐Ÿ‘‡

๐ŸŽด my-app.nuspec

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
  <metadata>
    <id>vidmerger</id>
    <version>0.1.2</version>
    <title>vidmerger</title>
    <authors>Thomas Gotwig</authors>
    <projectUrl>https://github.com/tgotwig/vidmerger</projectUrl>
    <tags>video cli</tags>
    <summary>A wrapper around ffmpeg which simplifies merging multiple videos ๐ŸŽž</summary>
    <description>Vidmerger is a command-line-tool which uses `ffmpeg` to merge multiple video-files with the same file-extension together into one file called `output.FORMAT`. It includes a usage help which you can print out by `vidmerger --help` ๐Ÿ˜ƒ</description>
  </metadata>
  <files>
    <file src="tools\**" target="tools" />
  </files>
</package>
Enter fullscreen mode Exit fullscreen mode

๐ŸŽด LICENSE.txt

Copyright 2020 Thomas Gotwig

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Enter fullscreen mode Exit fullscreen mode

๐ŸŽด VERIFICATION.txt

Generated by `CertUtil -hashfile vidmerger.exe SHA256`:

1268967539be0449126438887170c779aaea6fdbf4d835e529c77d4c56a7f75d
Enter fullscreen mode Exit fullscreen mode

Think on updating the hash inside of VERIFICATION.txt before pushing ๐Ÿง

๐Ÿš€ Pushing

Before you can push something, you'll need to login on your choco-cli first, to do so, go on https://chocolatey.org/account, do a login there and click on Show API Key, run that listed commands in your console.

Finally lets push it to Chocolatey! ๐Ÿ˜ƒ

choco pack
Get-ChildItem *.nupkg | ren -NewName vidmerger.nupkg
choco push vidmerger.nupkg --source https://push.chocolatey.org
Remove-Item vidmerger.nupkg
Enter fullscreen mode Exit fullscreen mode

That's all! ๐Ÿ˜Š๐Ÿซ

Top comments (0)