| title | Using winapp CLI with Rust |
|---|---|
| description | Learn how to use the winapp CLI with Rust applications to add package identity, access Windows APIs, and package as MSIX. |
| ms.date | 02/20/2026 |
| ms.topic | how-to |
This guide demonstrates how to use the winapp CLI with a Rust application to debug with package identity and package your application as an MSIX.
Package identity is a core concept in the Windows app model. It allows your application to access specific Windows APIs (like Notifications, Security, AI APIs, etc.), have a clean install/uninstall experience, and more.
-
Rust Toolchain: Install Rust using rustup or winget:
winget install Rustlang.Rustup --source winget -
winapp CLI: Install the
winapptool via winget:winget install microsoft.winappcli --source winget
cargo new rust-app
cd rust-appRun it to make sure everything is working:
cargo runAdd the windows dependency to your Cargo.toml:
cargo add windows --features ApplicationModelReplace the contents of src/main.rs:
use windows::ApplicationModel::Package;
fn main() {
match Package::Current() {
Ok(package) => {
match package.Id() {
Ok(id) => match id.FamilyName() {
Ok(name) => println!("Package Family Name: {}", name),
Err(e) => println!("Error getting family name: {}", e),
},
Err(e) => println!("Error getting package ID: {}", e),
}
}
Err(_) => println!("Not packaged"),
}
}cargo runYou should see "Not packaged".
winapp initWhen prompted:
- Package name: Press Enter to accept the default (rust-app)
- Publisher name: Press Enter to accept the default or enter your name
- Version: Press Enter to accept 1.0.0.0
- Entry point: Press Enter to accept the default (rust-app.exe)
- Setup SDKs: Select "Do not setup SDKs"
This creates appxmanifest.xml and Assets folder for your app identity.
-
Build the executable:
cargo build
-
Apply debug identity:
winapp create-debug-identity .\target\debug\rust-app.exe
-
Run the executable (do not use
cargo runas it might rebuild):.\target\debug\rust-app.exe
You should see:
Package Family Name: rust-app_12345abcde
-
Build for release:
cargo build --release -
Prepare package directory:
mkdir dist copy .\target\release\rust-app.exe .\dist\ -
Generate a development certificate:
winapp cert generate --if-exists skip
-
Package and sign:
winapp pack .\dist --cert .\devcert.pfx -
Install the certificate (run as administrator):
winapp cert install .\devcert.pfx
-
Install and run:
Add-AppxPackage .\rust-app.msix rust-app
Tip
- Sign your MSIX with a code signing certificate from a Certificate Authority for production distribution.
- The Microsoft Store signs the MSIX for you, no need to sign before submission.
- You may need separate MSIX packages for each architecture you support (x64, Arm64).