Rust for the Windows App SDK
Перейти к файлу
Kenny Kerr 52afa56f58
Update readme.md
2022-08-24 06:06:19 -06:00
.github Update readme.md 2022-08-24 06:06:19 -06:00
.metadata Cleanup DirectWrite Core support (#48) 2022-06-29 21:54:42 -07:00
.windows/winmd Cleanup DirectWrite Core support (#48) 2022-06-29 21:54:42 -07:00
crates Cleanup DirectWrite Core support (#48) 2022-06-29 21:54:42 -07:00
src Cleanup DirectWrite Core support (#48) 2022-06-29 21:54:42 -07:00
.gitattributes Initial Windows App SDK support 2021-06-24 15:31:45 -07:00
.gitignore Update crate (#36) 2022-03-20 14:29:52 -07:00
.rustfmt.toml Initial preview crate 2021-11-30 20:09:53 -08:00
Cargo.toml Cleanup DirectWrite Core support (#48) 2022-06-29 21:54:42 -07:00

.github/readme.md

This repository has been archived

The windows-app project was an experimental crate letting you call APIs from the Windows App SDK based on the technology from the windows crate. The Windows App SDK is however largely a vehicle for delivering out-of-band releases of Xaml, which is itself designed squarely for C# developers. While every effort has been made to support Rust, the Windows App SDK in its current form is too heavily tied to .NET and Visual Studio to be practically usable with other languages and toolchains. We hope this will change in future but for now this project has been archived.

Many thanks to @riverar who almost singlehandedly drove the research and development for the windows-app project.

Rust for the Windows App SDK

The windows-app crate lets you call any Windows App SDK (formerly known as Project Reunion) API using code generated from the metadata describing the API. It is powered by the windows crate.

Note: This is an experimental 🧪 crate and is not ready for production use.

Release channel coverage

The Windows App SDK is delivered via three release channels—experimental, preview, and stable. The windows-app crate currently targets APIs available in the preview and stable channels.

Getting started

It's very early days for the windows-app crate. To try it out, add the following to your Cargo.toml file:

[build-dependencies.windows-app]
git = "https://github.com/microsoft/windows-app-rs"
features = [
    "WindowsAppSdk_Foundation"
]

[dependencies.windows]
version = "0.37"

[dependencies.windows-app]
git = "https://github.com/microsoft/windows-app-rs"
features = [
    "WindowsAppSdk_Foundation",
    "Windows_System_Power"
]

Add a build script (build.rs) to your crate to deploy the Windows App SDK Bootstrapper with your app:

fn main() {
    ::windows_app::bootstrap::deploy::to_output_dir();
    
    // Temporary workaround for https://github.com/microsoft/WindowsAppSDK/issues/2634
    ::windows_app::build::embed_manifest(
        r#"<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
           <assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" />"#,
    )
}

Now make use of any Windows App SDK APIs as needed:

use ::windows_app::Microsoft::Windows::System::Power::*;
use ::windows_app::*;

fn main() -> ::windows::core::Result<()> {
    bootstrap::initialize()?;
    let charge = PowerManager::RemainingChargePercent()?;
    println!("Remaining charge: {charge}%");
    bootstrap::uninitialize()
}

Finally, install the Windows App Runtime on all target machines:

  1. Download the Windows App Runtime Redistributable package.
  2. Execute WindowsAppSDK-Installer-{arch}\WindowsAppRuntimeInstall.exe.

After you install the Windows App Runtime, it will be kept up-to-date by Microsoft via Windows Update.