diff --git a/FeatureFlags.psm1 b/FeatureFlags.psm1 index 69e936d..57cfd0a 100644 --- a/FeatureFlags.psm1 +++ b/FeatureFlags.psm1 @@ -18,23 +18,27 @@ function Get-FeatureFlagConfigFromFile([string]$jsonConfigPath) { } # Import the JSON and JSON schema libraries, and load the JSON schema. -# TODO: don't rely on versioned paths. Use dotnet build / pack properly. -$schemaLibPath = Join-Path -Path $PSScriptRoot -ChildPath "External/njsonschema/9.13.19/lib/netstandard1.0/NJsonSchema.dll" +$libs = Get-ChildItem -Recurse -Path "$PSScriptRoot/External" +$libs = $libs | Where-Object {$_.Extension -ieq ".dll" -and $_.FullName -ilike "*netstandard1.0*"} | ForEach-Object {$_.FullName} +$schemaLibPath = $libs | Where-Object {$_ -ilike "*NJsonSchema.dll"} if (-not (Test-Path -Path $schemaLibPath -PathType Leaf)) { Write-Error "Could not find the DLL for NJSonSchema: $schemaLibPath" } +Write-Verbose "Found NJsonSchema assembly at $schemaLibPath" -$jsonLibPath = Join-Path -Path $PSScriptRoot -ChildPath "External/newtonsoft.json/9.0.1/lib/netstandard1.0/Newtonsoft.Json.dll" +$jsonLibPath = $libs | Where-Object {$_ -ilike "*Newtonsoft.Json.dll"} if (-not (Test-Path -Path $jsonLibPath -PathType Leaf)) { Write-Error "Could not find the DLL for Newtonsoft.Json: $jsonLibPath" } +Write-Verbose "Found JSON.Net assembly at $jsonLibPath" try { - Add-Type -Path $jsonLibPath - Add-Type -Path $schemaLibPath + $jsonType = Add-Type -Path $jsonLibPath -PassThru + $jsonSchemaType = Add-Type -Path $schemaLibPath -PassThru + Write-Verbose "JSON.Net type: $jsonType" + Write-Verbose "NjsonSchema type: $jsonSchemaType" } catch { - Write-Error "Error loading JSON libraries" - Write-Host $_.Exception.LoaderExceptions + Write-Error "Error loading JSON libraries ($jsonLibPath, $schemaLibPath): $($_.Exception.Message)" } $script:schema = $null diff --git a/PowerShell-FeatureFlags.csproj b/PowerShell-FeatureFlags.csproj index 38d6a3e..35a59ea 100644 --- a/PowerShell-FeatureFlags.csproj +++ b/PowerShell-FeatureFlags.csproj @@ -1,7 +1,6 @@ - netstandard1.0 PowerShell_FeatureFlags