Note
Kailangan ng pahintulot para ma-access ang page na ito. Maaari mong subukang mag-sign in o magpalit ng mga direktoryo.
Ang pag-access sa pahinang ito ay nangangailangan ng pahintulot. Maaari mong subukang baguhin ang mga direktoryo.
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.
Prerequisites
Rust Toolchain: Install Rust using rustup or winget:
winget install Rustlang.Rustup --source wingetwinapp CLI: Install the
winapptool via winget:winget install microsoft.winappcli --source winget
1. Create a new Rust app
cargo new rust-app
cd rust-app
Run it to make sure everything is working:
cargo run
2. Update code to check identity
Add the windows dependency to your Cargo.toml:
cargo add windows --features ApplicationModel
Replace 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"),
}
}
3. Run without identity
cargo run
You should see "Not packaged".
4. Initialize project with winapp CLI
winapp init
When 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.
5. Debug with identity
Build the executable:
cargo buildApply debug identity:
winapp create-debug-identity .\target\debug\rust-app.exeRun the executable (do not use
cargo runas it might rebuild):.\target\debug\rust-app.exe
You should see:
Package Family Name: rust-app_12345abcde
6. Package with MSIX
Build for release:
cargo build --releasePrepare package directory:
mkdir dist copy .\target\release\rust-app.exe .\dist\Generate a development certificate:
winapp cert generate --if-exists skipPackage and sign:
winapp pack .\dist --cert .\devcert.pfxInstall the certificate (run as administrator):
winapp cert install .\devcert.pfxInstall 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).
Related topics
Windows developer