Modules/businessdev.ALbuild.Feeds/Public/Resolve-BcDependencyCeiling.ps1
|
function Resolve-BcDependencyCeiling { <# .SYNOPSIS Picks the BC version that dependency resolution should cap against, from the available sources. .DESCRIPTION Pure helper (no I/O, unit-testable) for the Resolve Dependencies task. The dependency version ceiling is the BC version being built against - NOT app.json 'application'/'platform', which are the app's *minimum* supported versions (using those as the ceiling makes the resolver reject real dependency apps built for the current BC and fall back to symbol-only AppSource packages). Precedence, highest first: 1. TargetVersionInput - an explicit pipeline value. Defaults (in the task) to $(bcArtifactVersion) from Get BC Artifact, so a CONTAINER-LESS build still honours the BC version it targets; can also be an author override. An unexpanded '$(...)' macro or an empty value is ignored (a container-less run leaves the default macro unexpanded). 2. InstalledApp - the platform app installed in the build container (exact build BC version); preserves the original container-based behaviour. 3. ConfigBcVersion - the 'bcVersion' pinned in albuild.json. Returns an empty Version (Source 'none') when nothing is available, so the caller resolves the newest version each app.json is compatible with. .PARAMETER TargetVersionInput The task's 'targetVersion' input value (may be empty or an unexpanded '$(...)' macro). .PARAMETER InstalledApp The apps installed in the build container (objects with Name/Version), or empty for none. .PARAMETER ConfigBcVersion The 'bcVersion' from albuild.json, or empty. .OUTPUTS PSCustomObject: Version (string, '' when none) and Source (string). #> [CmdletBinding()] [OutputType([PSCustomObject])] param( [string] $TargetVersionInput, [object[]] $InstalledApp = @(), [string] $ConfigBcVersion ) if ($TargetVersionInput -and $TargetVersionInput -notmatch '^\$\(.*\)$') { return [PSCustomObject]@{ Version = "$TargetVersionInput"; Source = 'targetVersion input' } } foreach ($name in 'Application', 'Base Application', 'System Application') { $platformApp = $InstalledApp | Where-Object { "$($_.Name)" -eq $name } | Select-Object -First 1 if ($platformApp -and $platformApp.Version) { return [PSCustomObject]@{ Version = "$($platformApp.Version)"; Source = 'build container platform app' } } } if ($ConfigBcVersion) { return [PSCustomObject]@{ Version = "$ConfigBcVersion"; Source = 'albuild.json bcVersion' } } return [PSCustomObject]@{ Version = ''; Source = 'none' } } |