Getting Started: Rust
Applies to
Windows
MacOS
Linux
Get started with our official cross-platform Rust crate.
tip
To find the most accurate and complete documentation for Rust please visit https://docs.rs/velopack
Quick Start
- Add Velopack to your
Cargo.toml
:
[dependencies]
velopack = { version = "0.0", features = ["async"] } # Replace with actual version and desired features
- Add the following code to your
main()
function:
use velopack::*;
fn main() {
// VelopackApp should be the first thing to run, in some circumstances it may terminate/restart the process to perform tasks.
VelopackApp::build().run();
// Your other app startup code here
}
- Add auto-updates somewhere to your app:
use velopack::*;
fn update_my_app() {
let source = sources::HttpSource::new("https://the.place/you-host/updates");
let um = UpdateManager::new(source, None, None).unwrap();
if let UpdateCheck::UpdateAvailable(updates) = um.check_for_updates().unwrap() {
// there was an update available. Download it.
um.download_updates(&updates, None).unwrap();
// download completed, let's restart and update
um.apply_updates_and_restart(&updates).unwrap();
}
}
- Build your app with cargo:
cargo build --release
- Install the
vpk
command line tool:
dotnet tool update -g vpk
Note: you must have the .NET Core SDK 8 installed to use and update vpk
- Package your Velopack release / installers:
vpk pack -u MyAppUniqueId -v 1.0.0 -p /target/release -e myexename.exe
✅ You're Done! Your app now has auto-updates and an installer.
You can upload your release to your website, or use the vpk upload
command to publish it to the destination of your choice.
Read the Velopack documentation at https://docs.velopack.io/ for more information.