manager
napt.build.manager
Build manager for PSADT package creation.
This module orchestrates the complete build process for creating PSADT packages from recipes and downloaded installers.
Design Principles
- Filesystem is source of truth for version information
- Entire PSADT Template_v4 structure copied unmodified
- Invoke-AppDeployToolkit.ps1 is generated from template (not copied)
- Build directories are versioned: {app_id}/{version}/
- Branding applied by replacing files in root Assets/ directory (v4 structure)
Example
Basic usage:
sanitize_filename
Sanitize string for use in Windows filename.
Rules
- Replace spaces with hyphens
- Remove invalid Windows filename characters (< > : " | ? * \ /)
- Normalize multiple consecutive hyphens to single hyphen
- Remove leading/trailing hyphens and dots
- If result is empty, fallback to app_id (or "app" if app_id is empty)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
String to sanitize (e.g., "Google Chrome"). |
required |
app_id
|
str
|
Fallback identifier if name becomes empty after sanitization. |
''
|
Returns:
| Type | Description |
|---|---|
str
|
Sanitized filename-safe string (e.g., "Google-Chrome"). |
Example
Basic sanitization:
sanitize_filename("Google Chrome") # Returns: "Google-Chrome"
sanitize_filename("My App v2.0") # Returns: "My-App-v2.0"
sanitize_filename("Test<>App") # Returns: "TestApp"
Fallback behavior:
Source code in napt/build/manager.py
build_package
build_package(
recipe_path: Path,
downloads_dir: Path | None = None,
output_dir: Path | None = None,
) -> BuildResult
Build a PSADT package from a recipe and downloaded installer.
This is the main entry point for the build process. It:
- Loads the recipe configuration
- Finds the downloaded installer
- Extracts version from installer (filesystem is truth)
- Gets/downloads PSADT release
- Creates build directory structure
- Copies PSADT files unmodified
- Generates Invoke-AppDeployToolkit.ps1 from template
- Copies installer to Files/
- Applies custom branding
- Generates detection script (always; used by App entry and by Update entry)
- Generates requirements script (when build_types is "both" or "update_only")
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
recipe_path
|
Path
|
Path to the recipe YAML file. |
required |
downloads_dir
|
Path | None
|
Directory containing the downloaded installer. Default: Path("downloads") |
None
|
output_dir
|
Path | None
|
Base directory for build output. Default: From config or Path("builds") |
None
|
Returns:
| Type | Description |
|---|---|
BuildResult
|
Build result containing app metadata, build paths, PSADT version, and generated script paths. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If recipe or installer doesn't exist. |
PackagingError
|
If build process fails or script generation fails. |
ConfigError
|
If required configuration is missing. |
Example
Basic build:
result = build_package(Path("recipes/Google/chrome.yaml"))
print(result.build_dir) # builds/napt-chrome/141.0.7390.123
print(result.build_types) # "both"
Custom output directory:
Note
Requires installer to be downloaded first (run 'napt discover'). Version extracted from installer file, not state cache. Overwrites existing build directory if it exists. PSADT files are copied unmodified from cache. Invoke-AppDeployToolkit.ps1 is generated (not copied). Scripts are generated as siblings to the packagefiles directory (not included in .intunewin package - must be uploaded separately to Intune). Detection script is always generated. The build_types setting controls requirements script only: "both" (default) generates detection and requirements, "app_only" generates only detection, "update_only" generates detection and requirements.
Source code in napt/build/manager.py
1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 | |