Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions FeatureFlags.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion PowerShell-FeatureFlags.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<!-- TODO: target .NET Standard 2.0 -->
<TargetFramework>netstandard1.0</TargetFramework>
<AssemblyName>PowerShell_FeatureFlags</AssemblyName>
<!-- Make sure dependencies are always copied in the output folder.
Expand Down
6 changes: 5 additions & 1 deletion tools/run-tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
$parentDir = Split-Path -Parent (Split-Path -Parent $PSCommandPath)
$testDir = Join-Path $parentDir -ChildPath "test"

Install-Module Pester -Force -Scope CurrentUser
$pester = Get-Module -ListAvailable | Where-Object {$_.Name -eq "Pester" -and $_.Version -gt '4.0.0'}
if ($pester.Count -eq 0) {
Write-Host "Cannot find the Pester module. Installing it."
Install-Module Pester -Force -Scope CurrentUser
}
$FailedTests = Invoke-Pester $testDir -EnableExit
if ($FailedTests -gt 0) {
Write-Error "Error: $FailedTests Pester tests failed."
Expand Down