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
# MIIa/gYJKoZIhvcNAQcCoIIa7zCCGusCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQU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