Skip to content

Commit

Permalink
Resolve framework assemblies from more .NET Core runtime packs, like …
Browse files Browse the repository at this point in the history
…"Microsoft.WindowsDesktop.App" etc.
  • Loading branch information
Rpinski committed Sep 28, 2019
1 parent 74f3b2a commit c12b5d6
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions ICSharpCode.Decompiler/Metadata/DotNetCorePathFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ public DotNetCorePackageInfo(string fullName, string type, string path, string[]
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;
ISet<string> packageBasePaths = new HashSet<string>(StringComparer.Ordinal);
readonly string assemblyName;
Expand Down Expand Up @@ -124,13 +131,16 @@ static IEnumerable<DotNetCorePackageInfo> LoadPackageInfos(string depsJsonFileNa

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;
}
Expand Down

0 comments on commit c12b5d6

Please sign in to comment.