Update ProjectContextBuilder and FrameworkReferenceResolver
This commit is contained in:
parent
7188f5b0a3
commit
94c239f74e
3 changed files with 41 additions and 44 deletions
|
@ -279,8 +279,6 @@ namespace Microsoft.DotNet.ProjectModel.Server
|
|||
return false;
|
||||
}
|
||||
|
||||
var frameworkReferenceResolver = FrameworkReferenceResolver.Default;
|
||||
|
||||
_local = Snapshot.CreateFromProject(state.Project);
|
||||
_local.ProjectDiagnostics = state.Diagnostics;
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.DotNet.ProjectModel.Graph;
|
||||
using Microsoft.DotNet.ProjectModel.Resolution;
|
||||
using Microsoft.Extensions.Internal;
|
||||
|
@ -154,7 +153,7 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
|
||||
RootDirectory = GlobalSettings?.DirectoryPath ?? RootDirectory;
|
||||
PackagesDirectory = PackagesDirectory ?? PackageDependencyProvider.ResolvePackagesPath(RootDirectory, GlobalSettings);
|
||||
ReferenceAssembliesPath = ReferenceAssembliesPath ?? GetDefaultReferenceAssembliesPath();
|
||||
ReferenceAssembliesPath = ReferenceAssembliesPath ?? FrameworkReferenceResolver.GetDefaultReferenceAssembliesPath();
|
||||
|
||||
LockFileLookup lockFileLookup = null;
|
||||
|
||||
|
@ -347,44 +346,6 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
}
|
||||
}
|
||||
|
||||
public static string GetDefaultReferenceAssembliesPath()
|
||||
{
|
||||
// Allow setting the reference assemblies path via an environment variable
|
||||
var referenceAssembliesPath = Environment.GetEnvironmentVariable("DOTNET_REFERENCE_ASSEMBLIES_PATH");
|
||||
|
||||
if (!string.IsNullOrEmpty(referenceAssembliesPath))
|
||||
{
|
||||
return referenceAssembliesPath;
|
||||
}
|
||||
|
||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
// There is no reference assemblies path outside of windows
|
||||
// The enviorment variable can be used to specify one
|
||||
return null;
|
||||
}
|
||||
|
||||
// References assemblies are in %ProgramFiles(x86)% on
|
||||
// 64 bit machines
|
||||
var programFiles = Environment.GetEnvironmentVariable("ProgramFiles(x86)");
|
||||
|
||||
if (string.IsNullOrEmpty(programFiles))
|
||||
{
|
||||
// On 32 bit machines they are in %ProgramFiles%
|
||||
programFiles = Environment.GetEnvironmentVariable("ProgramFiles");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(programFiles))
|
||||
{
|
||||
// Reference assemblies aren't installed
|
||||
return null;
|
||||
}
|
||||
|
||||
return Path.Combine(
|
||||
programFiles,
|
||||
"Reference Assemblies", "Microsoft", "Framework");
|
||||
}
|
||||
|
||||
private void EnsureProjectLoaded()
|
||||
{
|
||||
if (Project == null)
|
||||
|
|
|
@ -5,9 +5,9 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.DotNet.ProjectModel;
|
||||
using Microsoft.DotNet.ProjectModel.Utilities;
|
||||
using NuGet.Frameworks;
|
||||
|
||||
|
@ -43,12 +43,50 @@ namespace Microsoft.DotNet.ProjectModel.Resolution
|
|||
{
|
||||
if (_default == null)
|
||||
{
|
||||
_default = new FrameworkReferenceResolver(ProjectContextBuilder.GetDefaultReferenceAssembliesPath());
|
||||
_default = new FrameworkReferenceResolver(GetDefaultReferenceAssembliesPath());
|
||||
}
|
||||
|
||||
return _default;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetDefaultReferenceAssembliesPath()
|
||||
{
|
||||
// Allow setting the reference assemblies path via an environment variable
|
||||
var referenceAssembliesPath = Environment.GetEnvironmentVariable("DOTNET_REFERENCE_ASSEMBLIES_PATH");
|
||||
|
||||
if (!string.IsNullOrEmpty(referenceAssembliesPath))
|
||||
{
|
||||
return referenceAssembliesPath;
|
||||
}
|
||||
|
||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
// There is no reference assemblies path outside of windows
|
||||
// The enviorment variable can be used to specify one
|
||||
return null;
|
||||
}
|
||||
|
||||
// References assemblies are in %ProgramFiles(x86)% on
|
||||
// 64 bit machines
|
||||
var programFiles = Environment.GetEnvironmentVariable("ProgramFiles(x86)");
|
||||
|
||||
if (string.IsNullOrEmpty(programFiles))
|
||||
{
|
||||
// On 32 bit machines they are in %ProgramFiles%
|
||||
programFiles = Environment.GetEnvironmentVariable("ProgramFiles");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(programFiles))
|
||||
{
|
||||
// Reference assemblies aren't installed
|
||||
return null;
|
||||
}
|
||||
|
||||
return Path.Combine(
|
||||
programFiles,
|
||||
"Reference Assemblies", "Microsoft", "Framework");
|
||||
}
|
||||
|
||||
public bool TryGetAssembly(string name, NuGetFramework targetFramework, out string path, out Version version)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue