This sample demonstrates how to check for package identity and send Windows notifications from a Rust application.
For a complete step-by-step guide, see the Rust Getting Started Guide.
- Basic Rust console application
- Using Windows Runtime APIs to retrieve package identity
- Using
winapp runto run the app packaged (registers a loose layout package, just like a real MSIX install) - Sending Windows notifications with package identity
- MSIX packaging with app manifest and assets
- Rust toolchain (rustup or
winget install Rustlang.Rustup --source winget) - winapp CLI (
winget install microsoft.winappcli --source winget)
To run the application as a standard executable without package identity:
- Build the project:
cargo build
- Run the executable:
Output should be: "Not packaged"
.\target\debug\rust-app.exe
To run the application packaged with winapp run:
-
Build the project:
cargo build
-
Run packaged using
winapp run:winapp run .\target\debug --with-alias
This registers a loose layout package (just like a real MSIX install), then launches the app via its execution alias so console output stays in the current terminal.
Output should show the Package Family Name and trigger a notification.
Note: The
--with-aliasflag requires auap5:ExecutionAliasin the manifest. This sample'sappxmanifest.xmlalready includes one. You can add one to a appxmanifest.xml withwinapp manifest add-alias.
To fully package the application as an MSIX and install it:
-
Build for Release:
cargo build --release -
Prepare Packaging Directory:
mkdir msix copy .\target\release\rust-app.exe .\msix\(Note: Copy the exe and any other needed dependencies to this
msixfolder) -
Generate a Development Certificate (first time only):
winapp cert generate --if-exists skip
-
Pack the Application:
winapp pack .\msix --cert .\devcert.pfx -
Install the Certificate (first time only, requires Admin):
winapp cert install .\devcert.pfx
-
Install and Run:
- Double-click the generated
.msixfile to install. - Once installed, you can run it from the Start menu or by typing
winapp-rust-sample.exein your terminal.
- Double-click the generated