#manifest #build-script #build #build-environment #windows

build embed-manifest

Build script library to easily embed a Windows manifest

7 stable releases

1.4.0 Jun 21, 2023
1.3.1 Aug 7, 2022
1.3.0 May 1, 2022
1.2.1 Apr 18, 2022
1.0.0 Dec 18, 2021

#90 in Build Utils

Download history 68/week @ 2023-12-11 75/week @ 2023-12-18 218/week @ 2023-12-25 205/week @ 2024-01-01 175/week @ 2024-01-08 65/week @ 2024-01-15 86/week @ 2024-01-22 17/week @ 2024-01-29 34/week @ 2024-02-05 282/week @ 2024-02-12 268/week @ 2024-02-19 368/week @ 2024-02-26 293/week @ 2024-03-04 274/week @ 2024-03-11 283/week @ 2024-03-18 696/week @ 2024-03-25

1,600 downloads per month
Used in 2 crates

MIT license

73KB
1K SLoC

Windows Manifest Embedding for Rust

The embed-manifest crate provides a straightforward way to embed a Windows manifest in an executable, whatever the build environment, without dependencies on external tools from LLVM or MinGW.

If you need to embed more resources than just a manifest, you may find the winres or embed-resource crates more suitable. They have additional dependencies and setup requirements that may make them a little more difficult to use, though.

Why use it?

The Rust compiler doesn’t add a manifest to a Windows executable, which means that it runs with a few compatibility options and settings that make it look like the program is running on an older version of Windows. By adding an application manifest using this crate, even when cross-compiling:

  • 32-bit programs with names that look like installers don’t try to run as an administrator.
  • 32-bit programs aren’t shown a virtualised view of the filesystem and registry.
  • Many non-Unicode APIs accept UTF-8 strings, the same as Rust uses.
  • The program sees the real Windows version, not Windows Vista.
  • Built-in message boxes and other UI elements can display without blurring on high-DPI monitors.
  • Other features like long path names in APIs can be enabled.

Usage

To embed a default manifest, include this code in a build.rs build script:

use embed_manifest::{embed_manifest, new_manifest};

fn main() {
    if std::env::var_os("CARGO_CFG_WINDOWS").is_some() {
        embed_manifest(new_manifest("Contoso.Sample"))
            .expect("unable to embed manifest file");
    }
    println!("cargo:rerun-if-changed=build.rs");
}

See the crate documentation for information about how to customise the embedded manifest.

License

For the avoidance of doubt, while this crate itself is licensed to you under the MIT License, this does not affect the copyright status and licensing of your own code when this is used from a Cargo build script.

No runtime deps