Skip to content

Commit

Permalink
Fix #1720: Support new path structure of reference assemblies with .N…
Browse files Browse the repository at this point in the history
…ET Core 3.0
  • Loading branch information
Rpinski committed Sep 29, 2019
1 parent c729922 commit 82524f3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ILSpy.AddIn/AssemblyFileFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static bool IsReferenceAssembly(AssemblyDefinition assemblyDef, string as

static readonly string DetectTargetFrameworkIdRefPathPattern =
@"(Reference Assemblies[/\\]Microsoft[/\\]Framework[/\\](?<1>.NETFramework)[/\\]v(?<2>[^/\\]+)[/\\])" +
@"|(NuGetFallbackFolder[/\\](?<1>[^/\\]+)\\(?<2>[^/\\]+)([/\\].*)?[/\\]ref[/\\])";
@"|((NuGetFallbackFolder|packs)[/\\](?<1>[^/\\]+)\\(?<2>[^/\\]+)([/\\].*)?[/\\]ref[/\\])";

public static string DetectTargetFrameworkId(AssemblyDefinition assembly, string assemblyPath = null)
{
Expand All @@ -63,6 +63,7 @@ public static string DetectTargetFrameworkId(AssemblyDefinition assembly, string
*
* - .NETFramework -> C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\mscorlib.dll
* - .NETCore -> C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.1.0\ref\netcoreapp2.1\System.Console.dll
* -> C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\3.0.0\ref\netcoreapp3.0\System.Runtime.Extensions.dll
* - .NETStandard -> C:\Program Files\dotnet\sdk\NuGetFallbackFolder\netstandard.library\2.0.3\build\netstandard2.0\ref\netstandard.dll
*/
var pathMatch = Regex.Match(assemblyPath, DetectTargetFrameworkIdRefPathPattern,
Expand All @@ -73,9 +74,9 @@ public static string DetectTargetFrameworkId(AssemblyDefinition assembly, string

if (type == ".NETFramework") {
return $".NETFramework,Version=v{version}";
} else if (type.Contains("netcore")) {
} else if (type.ToLower().Contains("netcore")) {
return $".NETCoreApp,Version=v{version}";
} else if (type.Contains("netstandard")) {
} else if (type.ToLower().Contains("netstandard")) {
return $".NETStandard,Version=v{version}";
}
}
Expand Down

0 comments on commit 82524f3

Please sign in to comment.