RoyalDocument.PowerShell.psm1
# # Script module for module 'RoyalDocument.PowerShell' # Set-StrictMode -Version Latest $binarySubPath = 'netstandard2.0' $script:PSModule = $ExecutionContext.SessionState.Module $script:PSModuleRoot = $script:PSModule.ModuleBase $script:PSRoyalDoc = 'RoyalDocument.PowerShell.dll' $OneGetModulePath = Join-Path -Path $script:PSModuleRoot -ChildPath $script:PSRoyalDoc $binaryModuleRoot = $script:PSModuleRoot if (-not(Test-Path -Path $OneGetModulePath)) { # Import the appropriate nested binary module based on the current PowerShell version $binaryModuleRoot = Join-Path -Path $script:PSModuleRoot -ChildPath $binarySubPath $OneGetModulePath = Join-Path -Path $binaryModuleRoot -ChildPath $script:PSRoyalDoc } $OneGetModule = Import-Module -Name $OneGetModulePath -PassThru # When the module is unloaded, remove the nested binary module that was loaded with it if($OneGetModule) { $script:PSModule.OnRemove = { Remove-Module -ModuleInfo $OneGetModule } } # Workaround for assembly versioning issues on .NET Framework PowerShell if ($PSEdition -eq 'Desktop') { Add-Type -Path "$PSScriptRoot\Deps\Desktop\System.Buffers.dll" Add-Type -Path "$PSScriptRoot\Deps\Desktop\System.Runtime.CompilerServices.Unsafe.dll" } |