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 = Join-Path -Path 'coreclr' -ChildPath 'netstandard2.0' $binarySubPath = 'netstandard2.0' $script:Framework = 'netstandard2.0' } else { #$binarySubPath = 'fullclr' $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 $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 $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 $binaryModuleRoot -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($OneGetModule) #{ # $script:PSModule.OnRemove = { # Remove-Module -ModuleInfo $OneGetModule # } #} if($PSPSGetModule) { $script:PSModule.OnRemove = { Remove-Module -ModuleInfo $PSGetModule } } |