Use $env:CORE_ROOT if set, otherwise AppContext.BaseDirectory

Otherwise the Json.NET DLL cannot be found when Pester tests are run
over PSRP.
This commit is contained in:
Andrew Schwartzmeyer 2016-02-04 12:01:41 -08:00
parent 1d53e655f4
commit 5845a56d89

View File

@ -8,7 +8,12 @@ $here = Split-Path -Parent $MyInvocation.MyCommand.Path
Describe "Json.NET LINQ Parsing" {
# load third party Json.NET library
$base = [System.AppContext]::BaseDirectory
if ([string]::IsNullOrEmpty($env:CORE_ROOT)) {
$base = [System.AppContext]::BaseDirectory
} else {
$base = $env:CORE_ROOT
}
$path = Join-Path $base Newtonsoft.Json.dll
[Microsoft.PowerShell.CoreCLR.AssemblyExtensions]::LoadFrom($path)