msix_scripts
napt.build.msix_scripts
MSIX detection and requirements script generation for Intune Win32 apps.
This module generates PowerShell detection and requirements scripts for
MSIX packages deployed as Intune Win32 apps. Unlike MSI/EXE installers
that use registry-based detection, MSIX scripts query the AppX package
database. The query used depends on install_scope:
"system"(default): QueriesGet-AppxProvisionedPackage -Onlinefor provisioned (all-users) packages."user": QueriesGet-AppxPackage -Name <identity_name>for per-user packages.
For system-scope scripts, Version and Architecture are parsed from
PackageName (the package full name) rather than read from object
properties. The package full name format is
Name_Version_Architecture_ResourceId_PublisherId, where underscore is
the structural delimiter. The MSIX spec
(https://learn.microsoft.com/en-us/windows/apps/desktop/modernize/package-identity-overview)
explicitly prohibits underscores in all five components, so splitting on
_ is safe by design. Reading Architecture directly from the object
returns an integer enum value (e.g. 11 for neutral) that requires a
separate mapping step; parsing from PackageName yields the canonical
string form directly.
Detection Logic
- Queries the appropriate AppX store for the package identity
- Compares installed version against expected version
- Supports exact match or minimum version comparison
- Exits 0 if detected, 1 if not detected
Requirements Logic
- Queries the appropriate AppX store for the package identity
- If installed version < target version: outputs "Required"
- Otherwise: outputs nothing
- Always exits 0 so Intune can evaluate STDOUT
Logging
- Primary (System): C:\ProgramData\Microsoft\IntuneManagementExtension\Logs\NAPTDetections.log
- Primary (User): C:\ProgramData\Microsoft\IntuneManagementExtension\Logs\NAPTDetectionsUser.log
- Fallback locations mirror the registry-based scripts
- Format: CMTrace for compatibility with Intune diagnostics
Note
Detection and requirements scripts are saved as siblings to the packagefiles directory to prevent them from being included in the .intunewin package.
MSIXDetectionConfig
dataclass
Configuration for MSIX detection script generation.
Attributes:
| Name | Type | Description |
|---|---|---|
identity_name |
str
|
Package identity name for AppX package query (e.g., "com.tinyspeck.slackdesktop"). |
app_name |
str
|
Human-readable application name for logging and component identification. |
version |
str
|
Expected version string to match. |
log_rotation_mb |
int
|
Maximum log file size in MB before rotation. |
exact_match |
bool
|
If True, version must match exactly. If False, minimum version comparison (installed >= expected). |
install_scope |
InstallScope
|
Whether to query per-user ( |
Source code in napt/build/msix_scripts.py
MSIXRequirementsConfig
dataclass
Configuration for MSIX requirements script generation.
Attributes:
| Name | Type | Description |
|---|---|---|
identity_name |
str
|
Package identity name for AppX package query (e.g., "com.tinyspeck.slackdesktop"). |
app_name |
str
|
Human-readable application name for logging and component identification. |
version |
str
|
Target version string (requirement met if installed < this). |
log_rotation_mb |
int
|
Maximum log file size in MB before rotation. |
install_scope |
InstallScope
|
Whether to query per-user ( |
Source code in napt/build/msix_scripts.py
generate_msix_detection_script
Generates PowerShell detection script for MSIX Win32 app.
Creates a PowerShell script that queries the AppX package store for the
package identity (Get-AppxProvisionedPackage for system scope,
Get-AppxPackage for user scope) and compares the installed version
against the expected version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
MSIXDetectionConfig
|
MSIX detection configuration. |
required |
output_path
|
Path
|
Path where the detection script will be saved. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Path to the generated detection script. |
Raises:
| Type | Description |
|---|---|
PackagingError
|
If the script file cannot be written. |
Example
Generate script with default settings:
from pathlib import Path
from napt.build.msix_scripts import (
MSIXDetectionConfig,
generate_msix_detection_script,
)
config = MSIXDetectionConfig(
identity_name="com.tinyspeck.slackdesktop",
app_name="Slack",
version="4.49.81.0",
)
script_path = generate_msix_detection_script(
config,
Path("detection.ps1"),
)
Source code in napt/build/msix_scripts.py
generate_msix_requirements_script
Generates PowerShell requirements script for MSIX Win32 app.
Creates a PowerShell script that queries the AppX package store for the
package identity (Get-AppxProvisionedPackage for system scope,
Get-AppxPackage for user scope) and determines if an older version
is installed. Outputs "Required" if installed version < target, nothing
otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
MSIXRequirementsConfig
|
MSIX requirements configuration. |
required |
output_path
|
Path
|
Path where the requirements script will be saved. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
Path to the generated requirements script. |
Raises:
| Type | Description |
|---|---|
PackagingError
|
If the script file cannot be written. |
Example
Generate script with default settings:
from pathlib import Path
from napt.build.msix_scripts import (
MSIXRequirementsConfig,
generate_msix_requirements_script,
)
config = MSIXRequirementsConfig(
identity_name="com.tinyspeck.slackdesktop",
app_name="Slack",
version="4.49.81.0",
)
script_path = generate_msix_requirements_script(
config,
Path("requirements.ps1"),
)