Browse Source

Resolve framework assemblies from more .NET Core runtime packs, like "Microsoft.WindowsDesktop.App" etc.

pull/1728/head
Andreas Weizel 6 years ago
parent
commit
c12b5d60ec
  1. 24
      ICSharpCode.Decompiler/Metadata/DotNetCorePathFinder.cs

24
ICSharpCode.Decompiler/Metadata/DotNetCorePathFinder.cs

@ -53,6 +53,13 @@ namespace ICSharpCode.Decompiler.Metadata
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".nuget", "packages") Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".nuget", "packages")
}; };
static readonly string[] RuntimePacks = new[] {
"Microsoft.NETCore.App",
"Microsoft.WindowsDesktop.App",
"Microsoft.AspNetCore.App",
"Microsoft.AspNetCore.All"
};
readonly Dictionary<string, DotNetCorePackageInfo> packages; readonly Dictionary<string, DotNetCorePackageInfo> packages;
ISet<string> packageBasePaths = new HashSet<string>(StringComparer.Ordinal); ISet<string> packageBasePaths = new HashSet<string>(StringComparer.Ordinal);
readonly string assemblyName; readonly string assemblyName;
@ -124,13 +131,16 @@ namespace ICSharpCode.Decompiler.Metadata
string FallbackToDotNetSharedDirectory(IAssemblyReference name, Version version) string FallbackToDotNetSharedDirectory(IAssemblyReference name, Version version)
{ {
if (dotnetBasePath == null) return null; if (dotnetBasePath == null)
var basePath = Path.Combine(dotnetBasePath, "shared", "Microsoft.NETCore.App"); return null;
var closestVersion = GetClosestVersionFolder(basePath, version); var basePaths = RuntimePacks.Select(pack => Path.Combine(dotnetBasePath, "shared", pack));
if (File.Exists(Path.Combine(basePath, closestVersion, name.Name + ".dll"))) { foreach (var basePath in basePaths) {
return Path.Combine(basePath, closestVersion, name.Name + ".dll"); var closestVersion = GetClosestVersionFolder(basePath, version);
} else if (File.Exists(Path.Combine(basePath, closestVersion, name.Name + ".exe"))) { if (File.Exists(Path.Combine(basePath, closestVersion, name.Name + ".dll"))) {
return Path.Combine(basePath, closestVersion, name.Name + ".exe"); return Path.Combine(basePath, closestVersion, name.Name + ".dll");
} else if (File.Exists(Path.Combine(basePath, closestVersion, name.Name + ".exe"))) {
return Path.Combine(basePath, closestVersion, name.Name + ".exe");
}
} }
return null; return null;
} }

Loading…
Cancel
Save