Skip to content

Commit 8d2c8b1

Browse files
authored
Merge pull request #7 from clFaster/feature/make-pri-support
Feature/make pri support
2 parents 0252479 + 8532171 commit 8d2c8b1

6 files changed

Lines changed: 400 additions & 14 deletions

File tree

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ A Rust library and CLI tool for building and signing Windows MSIX packages and M
1717

1818
- **Multi-architecture support**: Build separate MSIX packages for x64 and ARM64 architectures
1919
- **Automatic bundle creation**: Combine per-architecture packages into a single `.msixbundle`
20-
- **SDK auto-discovery**: Automatically locate Windows SDK tools (`MakeAppx.exe`, `signtool.exe`, `appcert.exe`) via registry
20+
- **SDK auto-discovery**: Automatically locate Windows SDK tools (`MakeAppx.exe`, `makepri.exe`, `signtool.exe`, `appcert.exe`) via registry
21+
- **Resource indexing**: Optionally generate `resources.pri` with `makepri.exe` for qualified assets
2122
- **Code signing**: Sign packages and bundles with PFX certificates
2223
- **Timestamping**: Support for both RFC3161 and Authenticode timestamp protocols
2324
- **Validation**: Validate packages using Windows App Certification Kit (WACK) and verify signatures
@@ -26,7 +27,7 @@ A Rust library and CLI tool for building and signing Windows MSIX packages and M
2627
## Requirements
2728

2829
- **Windows OS**: This tool requires Windows and the Windows SDK
29-
- **Windows SDK 10**: MakeAppx.exe and signtool.exe must be installed
30+
- **Windows SDK 10**: MakeAppx.exe, MakePri.exe and signtool.exe must be installed
3031
- Install via [Visual Studio](https://visualstudio.microsoft.com/) or [standalone SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/)
3132
- **Windows App Certification Kit (WACK)**: Required for validation (appcert.exe)
3233
- Installed automatically with the Windows SDK
@@ -84,11 +85,12 @@ msixbundle-rs/
8485
## How It Works
8586

8687
1. **Manifest Parsing**: Reads `AppxManifest.xml` from each architecture directory to extract version and identity information
87-
2. **Package Creation**: Uses `MakeAppx.exe` to create `.msix` files for each architecture
88-
3. **Bundle Mapping**: Generates a `bundlemap.txt` file listing all architecture packages
89-
4. **Bundle Creation**: Uses `MakeAppx.exe` to combine packages into a `.msixbundle`
90-
5. **Signing**: Uses `signtool.exe` to apply digital signatures with optional timestamping
91-
6. **Validation**: Optionally validates packages with WACK and verifies signature validity
88+
2. **Resource Indexing (optional)**: Uses `makepri.exe` to generate `resources.pri`
89+
3. **Package Creation**: Uses `MakeAppx.exe` to create `.msix` files for each architecture
90+
4. **Bundle Mapping**: Generates a `bundlemap.txt` file listing all architecture packages
91+
5. **Bundle Creation**: Uses `MakeAppx.exe` to combine packages into a `.msixbundle`
92+
6. **Signing**: Uses `signtool.exe` to apply digital signatures with optional timestamping
93+
7. **Validation**: Optionally validates packages with WACK and verifies signature validity
9294

9395
## Contributing
9496

msixbundle-cli/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,19 @@ msixbundle-cli \
7272
--pfx-password "secret"
7373
```
7474

75+
### Generate resources.pri with MakePri
76+
77+
Generate `resources.pri` before packing (useful for scale-qualified assets such as `SquareLogo.scale-200.png`):
78+
79+
```bash
80+
msixbundle-cli \
81+
--out-dir ./output \
82+
--dir-x64 ./build/x64/AppxContent \
83+
--makepri \
84+
--makepri-default-language en-us \
85+
--makepri-target-os-version 10.0.0
86+
```
87+
7588
### With Validation and Verification
7689

7790
```bash
@@ -102,6 +115,11 @@ msixbundle-cli \
102115
| `--sip-dll` | Path to Appx SIP DLL (e.g., `C:\Windows\System32\AppxSip.dll`) |
103116
| `--timestamp-url` | Timestamp server URL (default: `http://timestamp.digicert.com`) |
104117
| `--timestamp-mode` | Timestamping protocol: `rfc3161` or `authenticode` (default: `rfc3161`) |
118+
| `--makepri` | Generate `resources.pri` with MakePri before packing |
119+
| `--makepri-path` | Override path to `makepri.exe` |
120+
| `--makepri-default-language` | Default language qualifier for MakePri (example: `en-us`) |
121+
| `--makepri-target-os-version` | MakePri `/pv` target OS version (example: `10.0.0`) |
122+
| `--makepri-keep-config` | Keep generated `priconfig.xml` files |
105123
| `--validate` | Validate packages using WACK (Windows App Certification Kit) |
106124
| `--verify` | Verify signatures with SignTool after signing |
107125
| `--verbose` | Enable verbose logging (sets `RUST_LOG=info`) |
@@ -157,6 +175,7 @@ openssl pkcs12 -export -out test-certificate.pfx -inkey private.key -in certific
157175

158176
- Windows OS with Windows SDK 10 installed
159177
- MakeAppx.exe and signtool.exe
178+
- makepri.exe (optional, required only with `--makepri`)
160179
- WACK (appcert.exe) for `--validate` option
161180

162181
## License

msixbundle-cli/src/main.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,26 @@ struct Args {
6161
#[arg(long, value_parser = ["rfc3161","authenticode"], default_value = "rfc3161")]
6262
timestamp_mode: String,
6363

64+
/// Generate resources.pri with MakePri before packing
65+
#[arg(long)]
66+
makepri: bool,
67+
68+
/// Override makepri.exe path
69+
#[arg(long, requires = "makepri")]
70+
makepri_path: Option<PathBuf>,
71+
72+
/// Default resource language for MakePri (for example: en-us)
73+
#[arg(long, default_value = "en-us", requires = "makepri")]
74+
makepri_default_language: String,
75+
76+
/// Target OS version for MakePri /pv (for example: 10.0.0)
77+
#[arg(long, default_value = "10.0.0", requires = "makepri")]
78+
makepri_target_os_version: String,
79+
80+
/// Keep generated priconfig.xml after MakePri
81+
#[arg(long, requires = "makepri")]
82+
makepri_keep_config: bool,
83+
6484
/// Validate packages with MakeAppx after build
6585
#[arg(long)]
6686
validate: bool,
@@ -106,6 +126,9 @@ fn main() -> Result<()> {
106126
if let Some(p) = &a.signtool_path {
107127
tools.signtool = Some(p.clone());
108128
}
129+
if let Some(p) = &a.makepri_path {
130+
tools.makepri = Some(p.clone());
131+
}
109132

110133
// Pack per-arch
111134
let mut built: Vec<(String, PathBuf)> = Vec::new();
@@ -114,6 +137,20 @@ fn main() -> Result<()> {
114137
if let Some(dir) = &a.dir_x64 {
115138
let dir = resolve_path(dir)?;
116139
let m = read_manifest_info(&dir)?;
140+
if a.makepri {
141+
let pri = compile_resources_pri(
142+
&tools,
143+
&PriOptions {
144+
appx_content_dir: &dir,
145+
default_language: a.makepri_default_language.as_str(),
146+
target_os_version: a.makepri_target_os_version.as_str(),
147+
keep_priconfig: a.makepri_keep_config,
148+
overwrite: a.force,
149+
makepri_override: None,
150+
},
151+
)?;
152+
info!("x64 PRI: {}", pri.display());
153+
}
117154
info = Some(m.clone());
118155
info!("x64: {}", dir.display());
119156
let msix = pack_arch(&tools, &dir, &out_dir, &m, "x64", a.force)?;
@@ -134,6 +171,20 @@ fn main() -> Result<()> {
134171
} else {
135172
info = Some(m.clone());
136173
}
174+
if a.makepri {
175+
let pri = compile_resources_pri(
176+
&tools,
177+
&PriOptions {
178+
appx_content_dir: &dir,
179+
default_language: a.makepri_default_language.as_str(),
180+
target_os_version: a.makepri_target_os_version.as_str(),
181+
keep_priconfig: a.makepri_keep_config,
182+
overwrite: a.force,
183+
makepri_override: None,
184+
},
185+
)?;
186+
info!("arm64 PRI: {}", pri.display());
187+
}
137188
info!("arm64: {}", dir.display());
138189
let msix = pack_arch(&tools, &dir, &out_dir, &m, "arm64", a.force)?;
139190
built.push(("arm64".into(), msix));

msixbundle/README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ msixbundle = "1.0"
1414
- **SDK auto-discovery**: Automatically locate Windows SDK tools via registry
1515
- **Manifest parsing**: Extract version and display name from `AppxManifest.xml`
1616
- **Package creation**: Create `.msix` files for each architecture
17+
- **Resource indexing**: Generate `resources.pri` with MakePri.exe
1718
- **Bundle creation**: Combine multiple `.msix` files into a `.msixbundle`
1819
- **Code signing**: Sign packages and bundles with PFX certificates or certificate store thumbprints
1920
- **Timestamping**: Support for RFC3161 and Authenticode protocols
@@ -25,6 +26,7 @@ msixbundle = "1.0"
2526
|----------|-------------|
2627
| `locate_sdk_tools()` | Find Windows SDK tools on the system |
2728
| `read_manifest_info()` | Parse AppxManifest.xml for version and identity |
29+
| `compile_resources_pri()` | Generate `resources.pri` for qualified asset resolution |
2830
| `pack_arch()` | Create a per-architecture .msix package |
2931
| `build_bundle()` | Combine multiple .msix files into a .msixbundle |
3032
| `sign_artifact()` | Sign packages/bundles with a PFX or certificate thumbprint |
@@ -46,6 +48,16 @@ fn main() -> anyhow::Result<()> {
4648
let manifest = read_manifest_info(x64_dir)?;
4749
println!("Building {} v{}", manifest.display_name, manifest.version);
4850

51+
// Optional: generate resources.pri for scale-qualified assets
52+
compile_resources_pri(&tools, &PriOptions {
53+
appx_content_dir: x64_dir,
54+
default_language: "en-us",
55+
target_os_version: "10.0.0",
56+
keep_priconfig: false,
57+
overwrite: true,
58+
makepri_override: None,
59+
})?;
60+
4961
// Pack architectures (last param: overwrite existing files)
5062
let out_dir = Path::new("./output");
5163
let x64_msix = pack_arch(&tools, x64_dir, out_dir, &manifest, "x64", true)?;
@@ -127,7 +139,9 @@ The library uses `anyhow::Result` for error handling and provides custom error t
127139
## Requirements
128140

129141
- Windows OS with Windows SDK 10 installed
130-
- MakeAppx.exe, signtool.exe, and appcert.exe (for validation)
142+
- MakeAppx.exe and signtool.exe
143+
- makepri.exe (optional, required for `compile_resources_pri()`)
144+
- appcert.exe (optional, required for validation)
131145

132146
## License
133147

0 commit comments

Comments
 (0)