Skip to content

Add configurable projectScanDepth for project discovery#2299

Closed
mazhelez wants to merge 1 commit into
microsoft:mainfrom
mazhelez:fix-project-discovery-depth
Closed

Add configurable projectScanDepth for project discovery#2299
mazhelez wants to merge 1 commit into
microsoft:mainfrom
mazhelez:fix-project-discovery-depth

Conversation

@mazhelez

@mazhelez mazhelez commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Problem

The \GetProjectsFromRepository\ function in \AL-Go-Helper.ps1\ uses a hardcoded -Depth 2\ when auto-discovering AL-Go projects (scanning for .AL-Go/settings.json\ directories). This means repositories that nest their projects deeper than 2 levels from the root cannot use automatic project discovery.

For example, a repository with projects at \�ng/AL-Go/projects/MyProject/.AL-Go/settings.json\ (depth 3) will not find any projects, leading to a strict mode error:
\
The variable '' cannot be retrieved because it has not been set.
\\

This happens because when no projects are found, the \if ()\ block is skipped, leaving \\ uninitialized, but line 231 still tries to access \.projectDependencies.

Fix

  1. *New setting: \projectScanDepth* (default: 2) — Controls the -Depth\ parameter for automatic project discovery. Repositories can increase this in .github/AL-Go-Settings.json:
    \\json
    { "projectScanDepth": 4 }
    \\

  2. Defensive initialization — \\ is now initialized with safe defaults before the \if ()\ guard, preventing strict mode errors when no projects are discovered.

  3. Schema update — Added \projectScanDepth\ to \settings.schema.json\ for IntelliSense support.

Files Changed

  • \Actions/.Modules/ReadSettings.psm1\ — Added default setting
  • \Actions/.Modules/settings.schema.json\ — Added schema definition
  • \Actions/AL-Go-Helper.ps1\ — Added -scanDepth\ parameter to \GetProjectsFromRepository; updated internal caller
  • \Actions/CheckForUpdates/CheckForUpdates.ps1\ — Pass \scanDepth\
  • \Actions/DetermineProjectsToBuild/DetermineProjectsToBuild.psm1\ — Pass \scanDepth; initialize \\
  • \Actions/IncrementVersionNumber/IncrementVersionNumber.ps1\ — Pass \scanDepth\

Backward Compatibility

The default value of 2 preserves existing behavior. Only repositories that explicitly set \projectScanDepth\ to a higher value will see different discovery behavior.

The GetProjectsFromRepository function used a hardcoded -Depth 2 for
auto-discovering AL-Go projects. This fails for repositories that nest
their projects deeper (e.g., eng/AL-Go/projects/MyProject/.AL-Go/).

Changes:
- Add 'projectScanDepth' setting (default: 2) to control discovery depth
- Pass the setting to all GetProjectsFromRepository callers
- Initialize $projectBuildInfo with defaults in DetermineProjectsToBuild
  to prevent strict mode errors when no projects are found
- Add projectScanDepth to settings schema

Repositories can now set projectScanDepth in .github/AL-Go-Settings.json:
  { "projectScanDepth": 4 }

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@mazhelez mazhelez closed this Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant