Getting Started: Rust
Get started with our official cross-platform Rust crate.
To find the most accurate and complete documentation for Rust please visit https://docs.rs/velopack
Quick Start
Install Velopack cargo crate
Add Velopack to your Cargo.toml
:
[dependencies]
velopack = { version = "0.0", features = ["async"] } # Replace with actual version and desired features
Configure Velopack at the beginning of main
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 update check within your app
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
Build your app with cargo:
cargo build --release
Install vpk
Velopack uses a command line tool called vpk
to package and publish releases.
It is distributed as a .NET global tool. Though Velopack can be used with app from various languages, the .NET is required to install and run vpk
.
You can install the .NET SDK from the .NET download page.
Once .NET is installed, you can install vpk
by running:
dotnet tool install -g vpk
Build Velopack release!
You are now ready to build a Velopack release for your application.
The --packId
can be any unique application identifier that you wish to use. Because this must be unique across all applications,
we recommend including your company name: <CompanyName>.<AppName>
.
The --mainExe
option is only required if your executable name is different than the --packId
of your application.
See the CLI reference for more details on the available options.
vpk pack --packId YourAppId --packVersion 1.0.0 --packDir .\publish --mainExe yourMainApp.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.
You can also check out our Sample Apps to see completed examples that leverage Velopack.