Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions ICSharpCode.Decompiler/Metadata/DotNetCorePathFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;

Expand Down Expand Up @@ -232,14 +233,36 @@ public string TryResolveDotNetCoreShared(IAssemblyReference name, out string run
string basePath = Path.Combine(dotnetBasePath, "shared", pack);
if (!Directory.Exists(basePath))
continue;
var closestVersion = GetClosestVersionFolder(basePath, targetFrameworkVersion);
if (File.Exists(Path.Combine(basePath, closestVersion, name.Name + ".dll")))
var foundVersions = new DirectoryInfo(basePath).GetDirectories()
.Select(ConvertToVersion)
.Where(v => v.version != null);
foreach (var folder in foundVersions.OrderBy(v => v.version))
{
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 (folder.version >= targetFrameworkVersion
&& folder.directory.EnumerateFiles("*.dll", SearchOption.AllDirectories).Any())
{
var closestVersion = folder.directory.Name;
string[] exts = { ".dll", ".exe" };
foreach (var ext in exts)
{
var path = Path.Combine(basePath, closestVersion, name.Name + ext);
if (File.Exists(path))
{
try
{
AssemblyName assemblyName = AssemblyName.GetAssemblyName(path);
if (assemblyName.Version >= name.Version)
{
return path;
}
}
catch (Exception ex)
{
Trace.TraceWarning(ex.ToString());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swallowing exceptions is not allowed.

}
}
}
}
}
}
runtimePack = null;
Expand Down
Loading