packager
napt.build.packager
.intunewin package generation for NAPT.
This module handles creating .intunewin packages from built PSADT directories using Microsoft's IntuneWinAppUtil.exe tool.
Design Principles
- IntuneWinAppUtil.exe is cached per release under the cache root (directories.cache), not per build
- Package output is named by IntuneWinAppUtil.exe: Invoke-AppDeployToolkit.intunewin
- Tool is downloaded from Microsoft's official GitHub repository
Verification
The build manifest is the link between steps. Before packaging, the
installer inside the build is re-hashed against the manifest's
installer_sha256, and that hash is checked against the release
deployment state records when the caller supplies it. After packaging,
the manifest copied into the package folder gains the .intunewin's
filename and hash, which napt upload re-checks before sending.
Two runs of IntuneWinAppUtil never produce the same bytes (it generates
a fresh encryption key each time), so the .intunewin hash only ever
ties one package to one upload.
Filing
The package folder for the version being packaged is cleared and rebuilt, so it holds exactly what this run produced. Other versions' package folders are never touched.
PackageResult
dataclass
Result from creating a .intunewin package.
Attributes:
| Name | Type | Description |
|---|---|---|
build_dir |
Path
|
Path to the build directory. |
package_path |
Path
|
Path to the created .intunewin file. |
app_id |
str
|
Unique application identifier. |
version |
str
|
Application version. |
Source code in napt/build/packager.py
create_intunewin
create_intunewin(
build_dir: Path,
cache_dir: Path,
output_dir: Path | None = None,
tool_release: str = "latest",
expected_sha256: str | None = None,
) -> PackageResult
Creates a .intunewin package from a PSADT build version directory.
Uses Microsoft's IntuneWinAppUtil.exe tool to package the PSADT build into a .intunewin file for Intune deployment.
The output directory is versioned: packages/{app_id}/{version}/. That folder is cleared and rebuilt so it holds exactly what this run produced; other versions' package folders are never touched. Detection and requirements scripts are copied into the output directory so that 'napt upload' is self-contained and does not need the builds directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
build_dir
|
Path
|
Path to the version directory produced by 'napt build' (e.g., builds/google-chrome/144.0.7559.110/). Must contain a packagefiles/ subdirectory with a valid PSADT structure. |
required |
cache_dir
|
Path
|
The cache root (directories.cache). IntuneWinAppUtil.exe releases live under its intunewin/ folder, one per version. |
required |
output_dir
|
Path | None
|
Parent directory for package output. Default: packages/ (configurable via directories.package in org.yaml). |
None
|
tool_release
|
str
|
IntuneWinAppUtil.exe release to use, "latest" or a specific version (e.g., "1.8.6"). Default is "latest". |
'latest'
|
expected_sha256
|
str | None
|
Hash of the release deployment state records, or None when no release is recorded. The build's installer must match it. |
None
|
Returns:
| Type | Description |
|---|---|
PackageResult
|
Package metadata including .intunewin path, app ID, and version. |
Raises:
| Type | Description |
|---|---|
ConfigError
|
If the build directory structure is invalid, or its manifest is missing or unusable. |
PackagingError
|
If the build's installer does not match its manifest or the recorded release, a script the manifest names is missing, packaging fails, or build_dir is missing. |
NetworkError
|
If IntuneWinAppUtil.exe download fails. |
Example
Basic packaging:
Note
Requires build directory from 'napt build' command. IntuneWinAppUtil.exe is downloaded and cached on first use. Setup file is always "Invoke-AppDeployToolkit.exe". Output file is named by IntuneWinAppUtil.exe: packages/{app_id}/{version}/Invoke-AppDeployToolkit.intunewin
Source code in napt/build/packager.py
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 | |