Add configurable projectScanDepth for project discovery#2299
Closed
mazhelez wants to merge 1 commit into
Closed
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
*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 }
\\
Defensive initialization — \\ is now initialized with safe defaults before the \if ()\ guard, preventing strict mode errors when no projects are discovered.
Schema update — Added \projectScanDepth\ to \settings.schema.json\ for IntelliSense support.
Files Changed
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.