private/scripts/libraryimport.ps1
if ($PSVersionTable.PSEdition -eq "Core") { $names = @( 'Microsoft.SqlServer.Server', 'Microsoft.SqlServer.Dac', 'Microsoft.SqlServer.Smo', 'Microsoft.SqlServer.SmoExtended', 'Microsoft.SqlServer.SqlWmiManagement', 'Microsoft.SqlServer.Management.RegisteredServers', 'Microsoft.SqlServer.Management.Collector', 'Microsoft.SqlServer.Management.XEvent', 'Microsoft.SqlServer.Management.XEventDbScoped', 'Microsoft.SqlServer.XEvent.XELite', '../third-party/LumenWorks/LumenWorks.Framework.IO' 'Azure.Core', 'Azure.Identity', 'Microsoft.IdentityModel.Abstractions' ) } else { $names = @( 'Microsoft.SqlServer.Dac', 'Microsoft.SqlServer.Smo', 'Microsoft.SqlServer.SmoExtended', 'Microsoft.SqlServer.SqlWmiManagement', 'Microsoft.SqlServer.Management.RegisteredServers', 'Microsoft.SqlServer.Management.IntegrationServices', 'Microsoft.SqlServer.Management.Collector', 'Microsoft.SqlServer.Management.XEvent', 'Microsoft.SqlServer.Management.XEventDbScoped', 'Microsoft.SqlServer.XEvent.XELite', 'Azure.Core', 'Azure.Identity', 'Microsoft.IdentityModel.Abstractions', 'Microsoft.Data.SqlClient', '../third-party/LumenWorks/LumenWorks.Framework.IO' ) } # XEvent stuff kills CI/CD if ($PSVersionTable.OS -match "ARM64") { $names = $names | Where-Object { $PSItem -notmatch "XE" } } #endregion Names # this takes 10ms $assemblies = [System.AppDomain]::CurrentDomain.GetAssemblies() try { $null = Import-Module ([IO.Path]::Combine($script:libraryroot, "third-party", "bogus", "bogus.dll")) } catch { Write-Error "Could not import $assemblyPath : $($_ | Out-String)" } foreach ($name in $names) { if ($name.StartsWith("win-sqlclient\") -and ($isLinux -or $IsMacOS)) { $name = $name.Replace("win-sqlclient\", "") if ($IsMacOS -and $name -in "Azure.Core", "Azure.Identity", "System.Security.SecureString") { $name = "mac\$name" } } $x64only = 'Microsoft.SqlServer.Replication', 'Microsoft.SqlServer.XEvent.Linq', 'Microsoft.SqlServer.BatchParser', 'Microsoft.SqlServer.Rmo', 'Microsoft.SqlServer.BatchParserClient' if ($name -in $x64only -and $env:PROCESSOR_ARCHITECTURE -eq "x86") { Write-Verbose -Message "Skipping $name. x86 not supported for this library." continue } $assemblyPath = [IO.Path]::Combine($script:libraryroot, "lib", "$name.dll") $assemblyfullname = $assemblies.FullName | Out-String if (-not ($assemblyfullname.Contains("$name,".Replace("win-sqlclient\", "")))) { $null = try { $null = Import-Module $assemblyPath } catch { Write-Error "Could not import $assemblyPath : $($_ | Out-String)" } } } |