Organize related AL extensions in one workspace

Completed

When several related extensions share dependencies or a common release schedule, working with each project in its own Visual Studio Code window becomes hard to coordinate. A multi-root workspace groups those projects so you can build, reference, and publish them together.

Visual Studio Code's multi-root workspace feature lets you combine several project folders into a single workspace. The AL Language extension supports this feature for AL projects specifically:

  1. On the File menu, select Add Folder to Workspace for each related AL project you want to include.
  2. Save the workspace to create a .code-workspace file. This file lists the included folders by path and stores workspace-level settings. Use relative paths so the file works for every teammate who opens the workspace from a different local location.
  3. Reopen the saved .code-workspace file to restore the same set of projects in one window.

Learn more in Work with multiple AL project folders within one workspace.

A workspace doesn't have to contain only AL projects. You can mix AL projects with other folder types, and each AL project keeps its own app.json, launch.json, and dependency configuration. Settings such as al.packageCachePath and al.enableCodeAnalysis can be set at the user, workspace, or individual project level, so a workspace-level value applies to every included project unless a specific project overrides it.

Order builds and dependencies across projects

When one project in the workspace declares another workspace project as a dependency in its app.json file, that dependency is a project reference. Project references have two practical advantages over downloaded symbol packages: you don't need to manually redownload symbols when the referenced project changes, and the AL Language extension resolves updated members as you edit the referenced project.

Project references also introduce an order you need to respect when you build and publish:

  • Building a project with Ctrl+Shift+B copies its .app file into the .alpackages folder of every project in the workspace that depends on it, and rebuilds any dependent project references that are out of date.
  • Publishing with Ctrl+F5 publishes the full set of changed projects in the dependency chain, using the active project as the startup project. If project C depends on project B, which depends on project A, and all three changed, publishing project C also publishes project A and project B in the correct order.
  • If only the top-level project changed, publishing it alone is sufficient. But if a lower-level project changed, you must rebuild and republish the chain so every dependent project compiles against the current state of its dependencies.

If reference resolution stops working, for example after a source control operation such as a pull, run the Reload Window command (Ctrl+R) to reinitialize the workspace, or rebuild the project reference directly. Learn more in Work with multiple projects and project references.

For workspaces with several project-to-project references, the al.incrementalBuild setting can shorten build times. When enabled, symbol resolution happens directly from the referenced project instead of from a cached .app file in the package cache folder, so the compiler works from the most current state of each dependency without an extra package rebuild step in between.

As a project loads in the workspace, Visual Studio Code also loads its project references as a transitive operation, and features such as IntelliSense aren't available for a project until loading finishes. Projects that haven't finished loading are decorated with the letter N in the Explorer view, which is a useful signal that a build or navigation issue is caused by an in-progress load rather than an actual configuration error.

Scope settings and source control per project

Keep source control boundaries aligned with project boundaries. Each AL project's .gitignore should exclude generated folders such as .alpackages and .altemplates, so the repository tracks source files and configuration, not downloaded symbols or build artifacts. The shared .code-workspace file is a convenient place to store workspace-wide settings such as a common al.packageCachePath, but avoid placing personal or environment-specific values there if multiple developers share the same workspace file through source control.

When you onboard a new project into an existing workspace, verify that its idRange in app.json doesn't overlap another project's range, and confirm its dependencies reference the other workspace projects by the correct id, name, publisher, and exact version. A workspace that keeps these boundaries consistent lets every developer add or update a project without breaking the projects around it.