Skip to content

Commit

Permalink
Merge pull request #33 from pwsh-cs-tools/patch-v0.4.1
Browse files Browse the repository at this point in the history
Patch: 0.4.1 - Add Support for Framework-Agnostic (OS-Agnostic Only) Files
  • Loading branch information
anonhostpi committed Jan 12, 2024
2 parents 44653f8 + 6561f2a commit b286848
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Import-Package/Import-Package.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = '.\Import-Package.psm1'

# Version number of this module.
ModuleVersion = '0.4.0'
ModuleVersion = '0.4.1'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
33 changes: 28 additions & 5 deletions Import-Package/Import-Package.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -329,17 +329,40 @@ function Import-Package {
}
}

$dlls = @{}
$dlls = @{
"lib" = [System.Collections.ArrayList]::new()
}
Write-Verbose "[Import-Package:Loading] Locating OS-agnostic dlls"
$short_folder_name = $TargetFramework.GetShortFolderName()
If( Test-Path "$(Split-Path $PackageData.Source)\lib\$short_folder_name" ){
If( Test-Path "$(Split-Path $PackageData.Source)\lib" ){
Write-Verbose "[Import-Package:Loading] Locating OS-agnostic framework-agnostic dlls"
Try {
$dlls.lib = Resolve-Path "$(Split-Path $PackageData.Source)\lib\$short_folder_name\*.dll" -ErrorAction Stop
Write-Verbose "[Import-Package:Loading] Found $( $dlls.lib.Count ) OS-agnostic native dlls"
$agnostic_dlls = Resolve-Path "$(Split-Path $PackageData.Source)\lib\*.dll" -ErrorAction Stop
Switch( $agnostic_dlls.Count ){
0 {}
1 { $dlls.lib.Add( $agnostic_dlls ) | Out-Null }
default { $dlls.lib.AddRange( $agnostic_dlls ) | Out-Null }
}
Write-Verbose "[Import-Package:Loading] Found $( $dlls.lib.Count ) OS-agnostic framework-agnostic dlls"
} Catch {
Write-Verbose "[Import-Package:Loading] Unable to find OS-agnostic dlls for $($PackageData.Name)"
Write-Verbose "[Import-Package:Loading] Unable to find OS-agnostic framework-agnostic dlls for $($PackageData.Name)"
return
}
If( Test-Path "$(Split-Path $PackageData.Source)\lib\$short_folder_name" ){
Write-Verbose "[Import-Package:Loading] Locating OS-agnostic dlls for $short_folder_name"
Try {
$framework_dlls = Resolve-Path "$(Split-Path $PackageData.Source)\lib\$short_folder_name\*.dll" -ErrorAction Stop
Switch( $framework_dlls.Count ){
0 {}
1 { $dlls.lib.Add( $framework_dlls ) | Out-Null }
default { $dlls.lib.AddRange( $framework_dlls ) | Out-Null }
}
Write-Verbose "[Import-Package:Loading] Found $( $dlls.lib.Count ) OS-agnostic dlls for $short_folder_name"
} Catch {
Write-Verbose "[Import-Package:Loading] Unable to find OS-agnostic dlls for $($PackageData.Name) for $short_folder_name"
return
}
}
}

Write-Verbose "[Import-Package:Loading] Locating OS-specific dlls"
Expand Down

0 comments on commit b286848

Please sign in to comment.