{"title":"Compile AL project - alcompile","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/al-agent-tools/al-tool-compile/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/al-agent-tools/al-tool-compile, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/al-agent-tools/al-tool-compile","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Learn about the al_compile tool available for AL development, including how to use it in Visual Studio Code with GitHub Copilot and through the AL MCP Server for headless environments and CI/CD pipelines.","date":"2026-10-02","meta":{"topic":"concept-article"},"outline":[{"level":1,"title":"Compile AL project - al_compile","slug":"compile-al-project---al_compile","at":0,"chars":3255},{"level":2,"title":"Parameters","slug":"parameters","at":687,"chars":775},{"level":2,"title":"Return value","slug":"return-value","at":1462,"chars":423},{"level":2,"title":"Examples","slug":"examples","at":1885,"chars":422},{"level":3,"title":"Validate the current workspace (errors only)","slug":"validate-the-current-workspace-errors-only","at":1897,"chars":145},{"level":3,"title":"Validate with all diagnostics and code analysis","slug":"validate-with-all-diagnostics-and-code-analysis","at":2042,"chars":174},{"level":3,"title":"Limit output in a large workspace","slug":"limit-output-in-a-large-workspace","at":2216,"chars":91},{"level":2,"title":"Diagnostics format","slug":"diagnostics-format","at":2307,"chars":263},{"level":2,"title":"Suggested next steps","slug":"suggested-next-steps","at":2570,"chars":289},{"level":2,"title":"Related tools","slug":"related-tools","at":2859,"chars":286},{"level":2,"title":"Related information","slug":"related-information","at":3145,"chars":110}],"text":"# Compile AL project - al_compile\nApplies to: AL Language extension 17.0 and later | Available in: AL MCP Server only\nThe al_compile tool compiles the AL workspace and returns diagnostics without generating an `.app` package. Because it skips the packaging step, it's faster than al_build<al-tool-build> and is the preferred choice for validation-only scenarios such as pull-request checks, precommit gates, and quick iterative feedback loops.\nUse al_build<al-tool-build> instead when you need the `.app` file-for example, before publishing.\n> NOTE\n> al_compile is available on the AL MCP Server only. In Visual Studio Code, use al_build with `scope=\"current\"` for an equivalent result.\n## Parameters\nAll parameters are optional and are passed as properties of a single options object.\nParameter|Type|Default|Description\nonlyErrors|boolean|true|When true (the default), only error-severity diagnostics are returned. Set to false to also receive warnings, informational messages, and hints.\nmaxDiagnosticsPerCompilation|integer|`100`|Maximum number of diagnostics to return per compilation. Increase this value if you expect a large number of issues.\nenableCodeAnalysis|boolean|(server default)|Enable AL code analyzers during compilation. When enabled, the analyzers listed in codeAnalyzers are run.\ncodeAnalyzers|string[]|(server default)|List of code analyzers to run. Supported values: `${CodeCop}`, `${AppSourceCop}`, `${PerTenantExtensionCop}`, `${UICop}`.\n## Return value\nThe tool returns a compilation result object with the following properties:\nProperty|Type|Description\nSucceeded|boolean|true if the compilation completed with no errors.\nDiagnostics|array|List of diagnostic items. Each item contains Severity, Code (for example, AL0118), Location (file and line), and Description (human-readable message).\nMessage|string|Optional extra context about the compilation result.\n## Examples\n### Validate the current workspace (errors only)\n```json\n{}\n```\nThe default behavior returns only errors, which is suitable for pass/fail gates.\n### Validate with all diagnostics and code analysis\n```json\n{\n  \"onlyErrors\": false,\n  \"enableCodeAnalysis\": true,\n  \"codeAnalyzers\": [\"${CodeCop}\", \"${AppSourceCop}\"]\n}\n```\n### Limit output in a large workspace\n```json\n{\n  \"maxDiagnosticsPerCompilation\": 50\n}\n```\n## Diagnostics format\nEach item in the Diagnostics array has the following structure:\n```json\n{\n  \"Severity\": \"Error\",\n  \"Code\": \"AL0118\",\n  \"Location\": \"MyCodeunit.al(42,15)\",\n  \"Description\": \"The name 'MyVariable' does not exist in the current context.\"\n}\n```\n## Suggested next steps\nOutcome|Suggested action\nNo errors|Proceed with al_build<al-tool-build> to generate the `.app` package.\nErrors reported|Fix the reported issues and rerun al_compile.\nSymbols not found|Run al_downloadsymbols<al-tool-download-symbols> to refresh the symbol packages.\n## Related tools\n al_build<al-tool-build> - Build and produce an `.app` package (both surfaces).\n al_getdiagnostics<al-tool-get-diagnostics> - Retrieve diagnostics with richer filtering options.\n al_downloadsymbols<al-tool-download-symbols> - Download symbol packages before compiling.\n## Related information\nAI agent tools overview<al-agent-tools-overview>\nAL MCP Server reference<al-mcp-server>"}