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 globally (not per-build)
- Package output is named by IntuneWinAppUtil.exe: Invoke-AppDeployToolkit.intunewin
- Build directory can optionally be cleaned after packaging
- Tool is downloaded from Microsoft's official GitHub repository
Example
Basic usage:
fetch_latest_intunewin_version
Fetch the latest IntuneWinAppUtil.exe release version from GitHub.
Queries the GitHub API for the latest release and extracts the version number from the tag name (e.g., "1.8.6" from tag "v1.8.6").
Returns:
| Type | Description |
|---|---|
str
|
Version number without "v" prefix (e.g., "1.8.6"). |
Raises:
| Type | Description |
|---|---|
NetworkError
|
If the GitHub API request fails or the version cannot be extracted from the response. |
Example
Get latest IntuneWinAppUtil version from GitHub:
Note
Uses GitHub's public API (60 requests/hour limit without auth). Set GITHUB_TOKEN environment variable for higher rate limits.
Source code in napt/build/packager.py
create_intunewin
create_intunewin(
build_dir: Path,
output_dir: Path | None = None,
clean_source: bool = False,
tool_release: str = "latest",
) -> PackageResult
Create 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}/. Any previously packaged version for the same app is removed before the new one is created (single-slot: one package on disk per app at a time). 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/napt-chrome/144.0.7559.110/). Must contain a packagefiles/ subdirectory with a valid PSADT structure. |
required |
output_dir
|
Path | None
|
Parent directory for package output. Default: packages/ (configurable via defaults.package.output_dir in org.yaml). |
None
|
clean_source
|
bool
|
If True, remove the build version directory after packaging. Default is False. |
False
|
tool_release
|
str
|
IntuneWinAppUtil.exe release to use — "latest" or a specific version (e.g., "1.8.6"). Default is "latest". |
'latest'
|
Returns:
| Type | Description |
|---|---|
PackageResult
|
Package metadata including .intunewin path, app ID, and version. |
Raises:
| Type | Description |
|---|---|
ConfigError
|
If the build directory structure is invalid. |
PackagingError
|
If packaging fails or build_dir is missing. |
NetworkError
|
If IntuneWinAppUtil.exe download fails. |
Example
Basic packaging:
result = create_intunewin(
build_dir=Path("builds/napt-chrome/144.0.7559.110")
)
print(result.package_path)
# packages/napt-chrome/144.0.7559.110/Invoke-AppDeployToolkit.intunewin
With cleanup:
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
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 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 | |