PSModule.psm1
# # Script module for module 'PowerShellGet' # Set-StrictMode -Version Latest # Summary: PowerShellGet is supported on Windows PowerShell 5.0 or later and PowerShellCore $isCore = ($PSVersionTable.Keys -contains "PSEdition") -and ($PSVersionTable.PSEdition -ne 'Desktop') #$binarySubPath = '' if ($isCore) { # $binarySubPath = 'netstandard2.0' $script:Framework = 'netstandard2.0' } else { # $binarySubPath = 'net472' $script:Framework = 'net472' } # Set up some helper variables to make it easier to work with the module $script:PSModule = $ExecutionContext.SessionState.Module $script:PSModuleRoot = $script:PSModule.ModuleBase #// the root of the current module .\ $script:PSGet = 'PowerShellGet.dll' # Try to import the PowerShellGet assemblies $PSGetFrameworkPath = Join-Path -Path $script:PSModuleRoot -ChildPath $script:Framework $PSGetModulePath = Join-Path -Path $PSGetFrameworkPath -ChildPath $script:PSGet // powershellget.dll #$binaryModuleRoot = $script:PSModuleRoot #if(-not (Test-Path -Path $PSGetModulePath)) #{ # Import the appropriate nested binary module based on the current PowerShell version # $binaryModuleRoot = Join-Path -Path $script:PSModuleRoot -ChildPath $binarySubPath # $PSGetModulePath = Join-Path -Path $binaryModuleRoot -ChildPath $script:PSGet #} #$PSPSGetModulePath = Join-Path -Path $script:PSModuleRoot -ChildPath $script:PSPSGet #$PSGetModule = Import-Module -Name $PSGetModulePath -PassThru #$PSPSGetModule = Import-Module -Name $PSPSGetModulePath -PassThru $PSGetModule = Import-Module -Name $PSGetModulePath -PassThru # When the module is unloaded, remove the nested binary module that was loaded with it if($PSGetModule) { $script:PSModule.OnRemove = { Remove-Module -ModuleInfo $PSGetModule } } #if($InBoxPSGetModule) #{ # $script:PSModule.OnRemove = { # Remove-Module -ModuleInfo $PSGetModule # } #} |