icons
napt.build.icons
App icon extraction from installers for NAPT builds.
Extracts a Company Portal-ready PNG icon from MSI, EXE, and MSIX installers at build time. Only icon frames that are already PNG-encoded are used (no image re-encoding), and frames must be at least 128px wide and no larger than 700KB. Among qualifying frames, the one closest to Intune's recommended 256px is selected.
Extraction sources per installer type:
- MSI: the Icon table (preferring the row named by ARPPRODUCTICON), then a fallback administrative extract of the MSI contents scanned for icons in the contained executables.
- EXE: RT_GROUP_ICON/RT_ICON resources parsed directly from the PE file.
- MSIX: logo assets declared in AppxManifest.xml, including scale and targetsize variants.
Backend Priority (MSI only):
- Windows: PowerShell COM (Windows Installer COM API, always available)
- Linux/macOS: msiinfo/msiextract (from the msitools package)
Note
Icon extraction is best-effort by design. The public entry point extract_icon_png never raises; a failure is reported through the returned result so the build can warn and continue. ensure_app_icon is the build step that keeps one icon per app in the icons directory.
IconExtraction
dataclass
Represents the outcome of an icon extraction attempt.
Attributes:
| Name | Type | Description |
|---|---|---|
png |
bytes | None
|
PNG file bytes ready to write to disk, or None if no qualifying icon frame was found. |
width |
int | None
|
Pixel width of the selected frame, or None on failure. |
detail |
str
|
Source description on success (e.g. the MSI Icon table row or MSIX asset used), or the failure cause on failure. |
Source code in napt/build/icons.py
extract_icon_png
Extracts the best available PNG icon from an installer file.
Dispatches on the installer suffix (.msi, .msix, .exe) and applies the
module's frame selection policy. This function never raises; failures
of any kind are reported through the returned result's detail field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
installer_path
|
str | Path
|
Path to the installer file. |
required |
Returns:
| Type | Description |
|---|---|
IconExtraction
|
Extraction outcome with PNG bytes and frame width on success, or a
failure cause in |
Example
Extract and save an icon:
Source code in napt/build/icons.py
ensure_app_icon
Extracts the app icon from the installer into the icons directory.
Best-effort side task that never raises: a failed extraction warns and the build continues. Skipped when intune.logo_path is set (the explicit icon wins at upload) or when the icon file already exists (users may drop curated replacements into the icons directory; NAPT never overwrites them).
A failed extraction is recorded in a {app_id}.no-icon marker so
expensive MSI extraction is not repeated every build. The marker
invalidates itself when the installer file changes and is removed on a
successful extraction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
dict[str, Any]
|
Merged effective configuration. |
required |
installer_file
|
Path
|
Path to the downloaded installer. |
required |
app_id
|
str
|
Recipe id; the icon is written to
|
required |
Source code in napt/build/icons.py
990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 | |