DosInstallUtilities.psm1

$script:ModuleRoot = "$PSScriptRoot"
$script:Assemblies = "$($script:ModuleRoot)\assemblies\DosInstallDependencies"

# Credit to https://powershellexplained.com/2017-01-21-powershell-module-continious-delivery-pipeline/?utm_source=blog&utm_medium=blog&utm_content=plasteradventures#module-manifest

Write-Verbose "Importing Functions"

# If we have a "compiled" module with all commands in 1 file - which is expected for the released module
# then import that as it is faster, otherwise dot source the functions and then export the public functions.
# The released/compiled version of the module also adds the public functions to the module manifest as functions
# to export

if (Test-Path $script:ModuleRoot\allcommands.ps1) {
    . $script:ModuleRoot\allcommands.ps1
} else  {
    foreach($folder in @('private', 'public'))
        {
            
            $root = Join-Path -Path $($script:ModuleRoot) -ChildPath $folder
            if(Test-Path -Path $root)
            {
                Write-Verbose "processing folder $root"
                $files = Get-ChildItem -Path $root -Filter *.ps1

                # dot source each file
                $files | where-Object{ $_.name -NotLike '*.Tests.ps1'}
                
                foreach ($file in $files) {
                    Write-Verbose "Importing $($file.name)"
                    . $file.FullName
                }
            }
        }

    Export-ModuleMember -Function (Get-ChildItem -Path "$($script:ModuleRoot)\public\*.ps1").basename
}

#Boot strapping logging
Add-Type -Path "$script:Assemblies\Serilog.dll"
Add-Type -Path "$script:Assemblies\Serilog.Sinks.File.dll"
Add-Type -Path "$script:Assemblies\Serilog.Sinks.Console.dll"
Add-Type -Path "$script:Assemblies\SerilogBridge.dll"

Set-DosMessageConfiguration -LoggingMode "Both" -MinimumLoggingLevel "Information" -LogFilePath "$env:SystemDrive/DosInstall/logs/DosInstall.log"

Add-Assembly -Assemblies @((Get-ChildItem -Path $script:Assemblies -Filter *.dll).FullName)
# SIG # Begin signature block
# MIIaxgYJKoZIhvcNAQcCoIIatzCCGrMCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQU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