Update DotNEtReferenceAssembliesPathResolver
This commit is contained in:
parent
dc7bab9e28
commit
78257e7388
4 changed files with 19 additions and 17 deletions
|
@ -208,7 +208,9 @@ namespace Microsoft.DotNet.ProjectModel.Resolution
|
||||||
private static FrameworkInformation GetFrameworkInformation(NuGetFramework targetFramework, string referenceAssembliesPath)
|
private static FrameworkInformation GetFrameworkInformation(NuGetFramework targetFramework, string referenceAssembliesPath)
|
||||||
{
|
{
|
||||||
// Check for legacy frameworks
|
// Check for legacy frameworks
|
||||||
if (targetFramework.IsDesktop() && targetFramework.Version <= new Version(3, 5))
|
if (PlatformServices.Default.Runtime.OperatingSystemPlatform == Platform.Windows &&
|
||||||
|
targetFramework.IsDesktop() &&
|
||||||
|
targetFramework.Version <= new Version(3, 5))
|
||||||
{
|
{
|
||||||
return GetLegacyFrameworkInformation(targetFramework, referenceAssembliesPath);
|
return GetLegacyFrameworkInformation(targetFramework, referenceAssembliesPath);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace Microsoft.Extensions.DependencyModel.Resolution
|
||||||
{
|
{
|
||||||
public static readonly string DotNetReferenceAssembliesPathEnv = "DOTNET_REFERENCE_ASSEMBLIES_PATH";
|
public static readonly string DotNetReferenceAssembliesPathEnv = "DOTNET_REFERENCE_ASSEMBLIES_PATH";
|
||||||
|
|
||||||
internal static string Resolve(IEnvironment envirnment)
|
internal static string Resolve(IEnvironment envirnment, IFileSystem fileSystem, IRuntimeEnvironment runtimeEnvironment)
|
||||||
{
|
{
|
||||||
var path = envirnment.GetEnvironmentVariable(DotNetReferenceAssembliesPathEnv);
|
var path = envirnment.GetEnvironmentVariable(DotNetReferenceAssembliesPathEnv);
|
||||||
if (!string.IsNullOrEmpty(path))
|
if (!string.IsNullOrEmpty(path))
|
||||||
|
@ -20,17 +20,17 @@ namespace Microsoft.Extensions.DependencyModel.Resolution
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetDefaultDotNetReferenceAssembliesPath();
|
return GetDefaultDotNetReferenceAssembliesPath(fileSystem, runtimeEnvironment);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string Resolve()
|
public static string Resolve()
|
||||||
{
|
{
|
||||||
return Resolve(EnvironmentWrapper.Default);
|
return Resolve(EnvironmentWrapper.Default, FileSystemWrapper.Default, PlatformServices.Default.Runtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetDefaultDotNetReferenceAssembliesPath()
|
private static string GetDefaultDotNetReferenceAssembliesPath(IFileSystem fileSystem, IRuntimeEnvironment runtimeEnvironment)
|
||||||
{
|
{
|
||||||
var os = PlatformServices.Default.Runtime.OperatingSystemPlatform;
|
var os = runtimeEnvironment.OperatingSystemPlatform;
|
||||||
|
|
||||||
if (os == Platform.Windows)
|
if (os == Platform.Windows)
|
||||||
{
|
{
|
||||||
|
@ -38,17 +38,17 @@ namespace Microsoft.Extensions.DependencyModel.Resolution
|
||||||
}
|
}
|
||||||
|
|
||||||
if (os == Platform.Darwin &&
|
if (os == Platform.Darwin &&
|
||||||
Directory.Exists("/Library/Framework/Mono.Framework/Versions/Current/lib/mono/xbuild-frameworks"))
|
fileSystem.Directory.Exists("/Library/Framework/Mono.Framework/Versions/Current/lib/mono/xbuild-frameworks"))
|
||||||
{
|
{
|
||||||
return "/Library/Framework/Mono.Framework/Versions/Current/lib/mono/xbuild-frameworks";
|
return "/Library/Framework/Mono.Framework/Versions/Current/lib/mono/xbuild-frameworks";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Directory.Exists("/usr/local/lib/mono/xbuild-frameworks"))
|
if (fileSystem.Directory.Exists("/usr/local/lib/mono/xbuild-frameworks"))
|
||||||
{
|
{
|
||||||
return "/usr/local/lib/mono/xbuild-frameworks";
|
return "/usr/local/lib/mono/xbuild-frameworks";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Directory.Exists("/usr/lib/mono/xbuild-frameworks"))
|
if (fileSystem.Directory.Exists("/usr/lib/mono/xbuild-frameworks"))
|
||||||
{
|
{
|
||||||
return "/usr/lib/mono/xbuild-frameworks";
|
return "/usr/lib/mono/xbuild-frameworks";
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace Microsoft.Extensions.DependencyModel.Resolution
|
||||||
|
|
||||||
internal ReferenceAssemblyPathResolver(IFileSystem fileSystem, IRuntimeEnvironment runtimeEnvironment, IEnvironment environment)
|
internal ReferenceAssemblyPathResolver(IFileSystem fileSystem, IRuntimeEnvironment runtimeEnvironment, IEnvironment environment)
|
||||||
: this(fileSystem,
|
: this(fileSystem,
|
||||||
GetDefaultReferenceAssembliesPath(runtimeEnvironment, environment),
|
GetDefaultReferenceAssembliesPath(runtimeEnvironment, fileSystem, environment),
|
||||||
GetFallbackSearchPaths(fileSystem, runtimeEnvironment, environment))
|
GetFallbackSearchPaths(fileSystem, runtimeEnvironment, environment))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -101,10 +101,10 @@ namespace Microsoft.Extensions.DependencyModel.Resolution
|
||||||
return new[] { net20Dir };
|
return new[] { net20Dir };
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static string GetDefaultReferenceAssembliesPath(IRuntimeEnvironment runtimeEnvironment, IEnvironment environment)
|
internal static string GetDefaultReferenceAssembliesPath(IRuntimeEnvironment runtimeEnvironment, IFileSystem fileSystem, IEnvironment environment)
|
||||||
{
|
{
|
||||||
// Allow setting the reference assemblies path via an environment variable
|
// Allow setting the reference assemblies path via an environment variable
|
||||||
var referenceAssembliesPath = DotNetReferenceAssembliesPathResolver.Resolve(environment);
|
var referenceAssembliesPath = DotNetReferenceAssembliesPathResolver.Resolve(environment, fileSystem, runtimeEnvironment);
|
||||||
if (!string.IsNullOrEmpty(referenceAssembliesPath))
|
if (!string.IsNullOrEmpty(referenceAssembliesPath))
|
||||||
{
|
{
|
||||||
return referenceAssembliesPath;
|
return referenceAssembliesPath;
|
||||||
|
|
|
@ -36,12 +36,12 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
||||||
{
|
{
|
||||||
var runtime = new Mock<IRuntimeEnvironment>();
|
var runtime = new Mock<IRuntimeEnvironment>();
|
||||||
runtime.SetupGet(r => r.OperatingSystemPlatform).Returns(Platform.Windows);
|
runtime.SetupGet(r => r.OperatingSystemPlatform).Returns(Platform.Windows);
|
||||||
|
|
||||||
var environment = EnvironmentMockBuilder.Create()
|
var environment = EnvironmentMockBuilder.Create()
|
||||||
.AddVariable("DOTNET_REFERENCE_ASSEMBLIES_PATH", ReferencePath)
|
.AddVariable("DOTNET_REFERENCE_ASSEMBLIES_PATH", ReferencePath)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var result = ReferenceAssemblyPathResolver.GetDefaultReferenceAssembliesPath(runtime.Object, environment);
|
var result = ReferenceAssemblyPathResolver.GetDefaultReferenceAssembliesPath(runtime.Object, FileSystemMockBuilder.Empty, environment);
|
||||||
result.Should().Be(ReferencePath);
|
result.Should().Be(ReferencePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
||||||
var runtime = new Mock<IRuntimeEnvironment>();
|
var runtime = new Mock<IRuntimeEnvironment>();
|
||||||
runtime.SetupGet(r => r.OperatingSystemPlatform).Returns(Platform.Linux);
|
runtime.SetupGet(r => r.OperatingSystemPlatform).Returns(Platform.Linux);
|
||||||
|
|
||||||
var result = ReferenceAssemblyPathResolver.GetDefaultReferenceAssembliesPath(runtime.Object, EnvironmentMockBuilder.Empty);
|
var result = ReferenceAssemblyPathResolver.GetDefaultReferenceAssembliesPath(runtime.Object, FileSystemMockBuilder.Empty, EnvironmentMockBuilder.Empty);
|
||||||
result.Should().BeNull();
|
result.Should().BeNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
||||||
.AddVariable("ProgramFiles", "Program Files")
|
.AddVariable("ProgramFiles", "Program Files")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var result = ReferenceAssemblyPathResolver.GetDefaultReferenceAssembliesPath(runtime.Object, environment);
|
var result = ReferenceAssemblyPathResolver.GetDefaultReferenceAssembliesPath(runtime.Object, FileSystemMockBuilder.Empty, environment);
|
||||||
result.Should().Be(Path.Combine("Program Files (x86)", "Reference Assemblies", "Microsoft", "Framework"));
|
result.Should().Be(Path.Combine("Program Files (x86)", "Reference Assemblies", "Microsoft", "Framework"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
|
||||||
.AddVariable("ProgramFiles", "Program Files")
|
.AddVariable("ProgramFiles", "Program Files")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var result = ReferenceAssemblyPathResolver.GetDefaultReferenceAssembliesPath(runtime.Object, environment);
|
var result = ReferenceAssemblyPathResolver.GetDefaultReferenceAssembliesPath(runtime.Object, FileSystemMockBuilder.Empty, environment);
|
||||||
result.Should().Be(Path.Combine("Program Files", "Reference Assemblies", "Microsoft", "Framework"));
|
result.Should().Be(Path.Combine("Program Files", "Reference Assemblies", "Microsoft", "Framework"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue