mirror of
https://github.com/freedbygrace/PSOPNSenseAPI.git
synced 2026-08-07 09:23:17 +00:00
Fix warnings, update version format, organize DLLs in subfolder, and use System.Reflection.Assembly::LoadBytes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
@{
|
||||
RootModule = 'PSOPNSenseAPI.dll'
|
||||
ModuleVersion = '2025.04.14.2246'
|
||||
RootModule = 'PSOPNSenseAPI.psm1'
|
||||
ModuleVersion = '2025.04.14.2253'
|
||||
GUID = '1f0e4b77-cc7c-4a1e-b45a-d7c51a3c562e'
|
||||
Author = 'PSOPNSenseAPI Contributors'
|
||||
CompanyName = 'PSOPNSenseAPI'
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
# Load assemblies from the lib folder using System.Reflection.Assembly::LoadBytes
|
||||
# This avoids file lock issues when the module is loaded
|
||||
|
||||
$libPath = Join-Path $PSScriptRoot "lib"
|
||||
$dllFiles = Get-ChildItem -Path $libPath -Filter "*.dll"
|
||||
|
||||
foreach ($dll in $dllFiles) {
|
||||
try {
|
||||
$dllBytes = [System.IO.File]::ReadAllBytes($dll.FullName)
|
||||
[System.Reflection.Assembly]::Load($dllBytes) | Out-Null
|
||||
Write-Verbose "Loaded assembly: $($dll.Name)"
|
||||
}
|
||||
catch {
|
||||
Write-Warning "Failed to load assembly $($dll.Name): $_"
|
||||
}
|
||||
}
|
||||
|
||||
# Export all cmdlets
|
||||
$cmdlets = [System.AppDomain]::CurrentDomain.GetAssemblies() |
|
||||
Where-Object { $_.FullName -like "*PSOPNSenseAPI*" } |
|
||||
ForEach-Object { $_.GetTypes() } |
|
||||
Where-Object { $_.IsPublic -and $_.IsClass -and $_.Name -like "*Cmdlet" } |
|
||||
ForEach-Object { $_.Name }
|
||||
|
||||
Export-ModuleMember -Cmdlet $cmdlets
|
||||
Binary file not shown.
Reference in New Issue
Block a user