From c12b5d60ec26d439907fd825dabb80fdf87d5448 Mon Sep 17 00:00:00 2001 From: Andreas Weizel Date: Sat, 28 Sep 2019 11:25:29 +0200 Subject: [PATCH] Resolve framework assemblies from more .NET Core runtime packs, like "Microsoft.WindowsDesktop.App" etc. --- .../Metadata/DotNetCorePathFinder.cs | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/ICSharpCode.Decompiler/Metadata/DotNetCorePathFinder.cs b/ICSharpCode.Decompiler/Metadata/DotNetCorePathFinder.cs index be76244ed..91937943b 100644 --- a/ICSharpCode.Decompiler/Metadata/DotNetCorePathFinder.cs +++ b/ICSharpCode.Decompiler/Metadata/DotNetCorePathFinder.cs @@ -53,6 +53,13 @@ namespace ICSharpCode.Decompiler.Metadata 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 packages; ISet packageBasePaths = new HashSet(StringComparer.Ordinal); readonly string assemblyName; @@ -124,13 +131,16 @@ namespace ICSharpCode.Decompiler.Metadata string FallbackToDotNetSharedDirectory(IAssemblyReference name, Version version) { - if (dotnetBasePath == null) return null; - var basePath = Path.Combine(dotnetBasePath, "shared", "Microsoft.NETCore.App"); - var closestVersion = GetClosestVersionFolder(basePath, version); - if (File.Exists(Path.Combine(basePath, closestVersion, name.Name + ".dll"))) { - 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"); + if (dotnetBasePath == null) + return null; + var basePaths = RuntimePacks.Select(pack => Path.Combine(dotnetBasePath, "shared", pack)); + foreach (var basePath in basePaths) { + var closestVersion = GetClosestVersionFolder(basePath, version); + if (File.Exists(Path.Combine(basePath, closestVersion, name.Name + ".dll"))) { + 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; }