#windows-installer #installer #windows #wrapper

build installer_lite

为您的应用程序创建简单的 Windows 安装程序

3 个稳定版本

1.0.2 2023 年 5 月 10 日

444构建工具 中排名

36 每月下载次数

MIT/Apache

11KB
188 代码行

Installer lite

为您的 Windows 应用程序创建简单的安装应用程序。将构成您二进制的字节存储在安装程序二进制文件中,然后将其写入请求的位置。 demo_app_installer_DPcp9pItUP

使用方法

  • 首先在您的 crates 根目录中创建一个 ./installer/installer.rs 文件。
  • 将二进制文件添加到您的 Cargo.toml 中,如下所示
[package]
name = "demo-app"
version = "1.0.0"
edition = "2021"
# First add the app you want to package as a bin
[[bin]]
name = "demo_app"
path = "src/main.rs"

# Then add the installer as such, must be second so it always
# builds after your main one
[[bin]]
name = "demo_app_installer"
path = "installer/installer.rs"

# and ofcourse add the dependency
[dependencies]
installer_lite = "1.0.0"
  • installer.rs 内部
use installer_lite::Installer;
use std::{env, path::PathBuf};

/* Make sure your app is built first, then include it's bytes */
static EXECUTABLE: &'static [u8] = include_bytes!("../target/release/demo_app.exe");
fn main() {
    let app_name = env!("CARGO_PKG_NAME");

    let mut installer = Installer::new(
        EXECUTABLE,
        None, // Defaults to C:\Program Files (x86)
        app_name.to_string(),
    );
    /* Support for pre and post install custom functions */
    installer.add_pre_install_function(Box::from(|| {
        println!("STARTING INSTALLATION HEHE");
        let console_output = "STARTING INSTALLATION HEHE".to_owned();
        return console_output;
    }));
    /* Start the installer, maybe handle error cases */
    installer.start().expect("Installation somehow failed");
}

依赖关系

~7–41MB
~663K SLoC