Merge pull request #2617 from schellap/fx-deps-file

Determine FX dir using FX_DEPS_FILE
This commit is contained in:
Senthil 2016-04-21 13:49:20 -07:00
commit 3d8cbba932
2 changed files with 17 additions and 3 deletions

View file

@ -28,7 +28,8 @@ namespace Microsoft.DotNet.Cli.Utils
{
if (_hostDir == null)
{
_hostDir = Path.GetDirectoryName(typeof(object).GetTypeInfo().Assembly.Location);
var fxDepsFile = Muxer.GetDataFromAppDomain("FX_DEPS_FILE");
_hostDir = Path.GetDirectoryName(fxDepsFile);
}
return _hostDir;

View file

@ -33,11 +33,24 @@ namespace Microsoft.DotNet.Cli.Utils
}
}
public static string GetDataFromAppDomain(string propertyName)
{
var appDomainType = typeof(object).GetTypeInfo().Assembly?.GetType("System.AppDomain");
var currentDomain = appDomainType?.GetProperty("CurrentDomain")?.GetValue(null);
var deps = appDomainType?.GetMethod("GetData")?.Invoke(currentDomain, new[] { propertyName });
return deps as string;
}
private bool TryResolveMuxerFromParentDirectories()
{
var appBase = new FileInfo(typeof(object).GetTypeInfo().Assembly.Location);
var muxerDir = appBase.Directory?.Parent?.Parent?.Parent;
var fxDepsFile = GetDataFromAppDomain("FX_DEPS_FILE");
if (string.IsNullOrEmpty(fxDepsFile))
{
return false;
}
var muxerDir = new FileInfo(fxDepsFile).Directory?.Parent?.Parent?.Parent;
if (muxerDir == null)
{
return false;