Skip to content

Commit

Permalink
Bugfix: Bundle Json Library
Browse files Browse the repository at this point in the history
Fixes #3
  • Loading branch information
JustinGrote committed Mar 19, 2019
1 parent a1f7313 commit b3fec6c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions PoshNmap/PoshNmap.psm1
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
#Get JSON settings files
$ModuleSettings = @( Get-ChildItem -Path $PSScriptRoot\Settings\*.json -ErrorAction SilentlyContinue )


#Determine which assembly versions to load
#See if .Net Standard 2.0 is available on the system and if not, load the legacy Net 4.0 library
try {
Add-Type -AssemblyName 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' -ErrorAction Stop
#If netstandard is not available it won't get this far
$dotNetTarget = "netstandard2"
} catch {
if ($psEdition -ne 'Core') {
$dotNetTarget = "net40-client"
}

$AssembliesToLoad = Get-ChildItem -Path "$PSScriptRoot\lib\*-$dotNetTarget.dll" -ErrorAction SilentlyContinue

if ($AssembliesToLoad) {
#If we are in a build or a pester test, load assemblies from a temporary file so they don't lock the original file
#This helps to prevent cleaning problems due to a powershell session locking the file because unloading a module doesn't unload assemblies
Expand All @@ -33,8 +24,9 @@ if ($AssembliesToLoad) {
$AssembliesToLoad = $TempAssembliesToLoad
}

write-verbose "Loading Assemblies for .NET target: $dotNetTarget"
Add-Type -Path $AssembliesToLoad.fullname -ErrorAction Stop
$assembliestoLoad | Foreach-Object {
[Reflection.Assembly]::LoadFile($AssembliesToLoad)
}
}

#Dot source the files
Expand All @@ -58,4 +50,4 @@ foreach ($ModuleSettingsItem in $ModuleSettings) {
New-Variable -Name "$($ModuleSettingsItem.basename)" -Scope Global -Value (convertfrom-json (Get-Content -raw $ModuleSettingsItem.fullname)) -Force
}

#Export the public functions. This requires them to match the standard Noun-Verb powershell cmdlet format as a safety mechanism
#Export the public functions. This requires them to match the standard Noun-Verb powershell cmdlet format as a safety mechanism
Binary file added PoshNmap/lib/Newtonsoft.Json-net40-client.dll
Binary file not shown.

0 comments on commit b3fec6c

Please sign in to comment.