Modules/businessdev.ALbuild.Feeds/businessdev.ALbuild.Feeds.psm1
|
#Requires -Version 5.1 Set-StrictMode -Version Latest # Root loader for businessdev.ALbuild.Feeds. # Dot-sources Classes -> Private -> Public and exports only the public functions. $ErrorActionPreference = 'Stop' $script:ModuleRoot = $PSScriptRoot # BC NuGet packages are ZIP archives; BcNuGetFeedProvider extracts them using System.IO.Compression # types referenced directly in a class method. A PowerShell class body is compiled when the module # loads, so the assembly must be present *before* the Classes are dot-sourced below. Windows # PowerShell 5.1 does not load System.IO.Compression by default (PowerShell 7 does), and a late # Add-Type inside the method would run after the class had already failed to compile. Add-Type -AssemblyName System.IO.Compression -ErrorAction SilentlyContinue # Module-scoped registry of feed providers, keyed by name (initialised for strict-mode safety). $script:BcFeedRegistry = [ordered]@{} foreach ($folder in 'Classes', 'Private', 'Public') { $path = Join-Path -Path $PSScriptRoot -ChildPath $folder if (-not (Test-Path -LiteralPath $path)) { continue } $files = Get-ChildItem -LiteralPath $path -Filter '*.ps1' -File -Recurse | Where-Object { $_.Name -notlike '*.Tests.ps1' } | Sort-Object FullName foreach ($file in $files) { try { . $file.FullName } catch { throw "businessdev.ALbuild.Feeds: failed to load '$($file.FullName)': $($_.Exception.Message)" } } } $publicFunctions = @() $publicPath = Join-Path -Path $PSScriptRoot -ChildPath 'Public' if (Test-Path -LiteralPath $publicPath) { $publicFunctions = @(Get-ChildItem -LiteralPath $publicPath -Filter '*.ps1' -File -Recurse | Where-Object { $_.Name -notlike '*.Tests.ps1' } | ForEach-Object { [System.IO.Path]::GetFileNameWithoutExtension($_.Name) }) } Export-ModuleMember -Function $publicFunctions |