| name | compile-system-app |
| description | Compile the System Application and/or System Application Tests AL-Go projects locally without spinning up a Business Central container. Use after editing AL code under `src/System Application/` or `src/Business Foundation/` to confirm the change still builds, or when the user asks to "compile system app", "build the test app", or similar. |
compile-system-app
Runs a container-less compile of the System Application AL-Go projects via build\scripts\DevEnv\NewDevEnv.psm1's Build-Apps function. It uses a CompilerFolder (BC artifacts in the package cache), so no Docker container is created or required.
When to use
- After editing
.al files under src/System Application/, src/Business Foundation/, or src/Tools/ to verify the change compiles.
- When the user asks to "compile", "build", or "check the system app builds".
- As a finishing step before reporting AL work as complete.
Do not use it to publish apps to a container or to run AL tests — those need a container (build\scripts\DevEnv\NewDevEnv.ps1) or VS Code F5.
How to run
From the repo root, invoke via Bash:
pwsh -File ".claude/skills/compile-system-app/Compile-SystemApp.ps1" -Target all
Targets:
-Target app — only build\projects\System Application (System App + Business Foundation + Tools + Test Libraries)
-Target tests — build\projects\System Application first (rebuilds Test Libraries), then build\projects\System Application Tests
-Target all (default) — same as tests (both projects, app first so the test project finds its dependency)
Nested module apps (-Module) — HIGHLY RECOMMENDED
Always use -Module <name> when editing code in a nested module (SharePoint, Email, Azure Key Vault, etc.). These modules are separate apps with their own app.json inside subdirectories of Test Library/ and Test/. Without -Module, the root System Application Tests project compiles ALL nested module files but resolves their dependencies from pre-built BC artifact symbols — which won't have locally-added methods, causing AL0132 "does not contain a definition" errors.
pwsh -File ".claude/skills/compile-system-app/Compile-SystemApp.ps1" -Target all -Module SharePoint
pwsh -File ".claude/skills/compile-system-app/Compile-SystemApp.ps1" -Target all -Module SharePoint,Email
When -Module is specified:
- The System Application project is compiled first (main app + root test library)
- Module test libraries (
Test Library/<Module>/) are compiled next
- The root System Application Tests project is skipped (avoids stale symbol conflicts)
- Module tests (
Test/<Module>/) are compiled separately with the freshly built dependencies
Flags:
-NoRebuild — skip the rebuild flag; reuses existing .app files in the cache. Faster, but a stale .app can mask a broken source change. Default behavior rebuilds.
What to expect
- First run is slow (several minutes): BcContainerHelper downloads the BC compiler/symbols matching the current branch's artifact URL into
bccache/sysapp-compile/. Subsequent runs reuse it and finish in tens of seconds to a couple of minutes per project.
- Exit code
0 = all targeted projects compiled. Exit code 1 = at least one project failed; the summary block lists which.
- Logging: All build output is captured to a timestamped log file in the artifacts folder (e.g.,
artifacts/sysapp-compile/compile-20260525-043000.log). The console only shows AL errors and the summary — this prevents output truncation from hiding errors. The full log path is printed at the top and bottom of the output. On failure, read the log file for full details instead of re-running the build.
Prerequisites
- PowerShell 7 (
pwsh) on PATH.
BcContainerHelper module installed (Install-Module BcContainerHelper -Scope CurrentUser -AllowPrerelease). The build infra auto-installs it on first container creation but this skill does not, since it avoids container code paths — install it once manually if missing.
- Working directory does not matter; the script resolves the repo root from its own location.
Troubleshooting
- "Module test library not found" — the
-Module name doesn't match a subdirectory of Test Library/ with an app.json. Check the folder name (case-sensitive on some platforms).
- "Module BcContainerHelper not found" — install it (see Prerequisites).
- Download of BC artifact hangs or fails — first run pulls hundreds of MB; ensure network access and retry.
- "No app/test folders resolved" —
build\projects\<name>\.AL-Go\settings.json is missing or malformed; check that path exists.
- Compile fails on a dependency you did not edit — run with
-Target app first to rebuild dependencies, then -Target tests.