Skip to content

Commit

Permalink
Get Razor compilation working with netcoreapp2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveSanderson committed Nov 6, 2017
1 parent a603d3e commit 594307c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Blazor.Compiler/ProjectReferenceUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using MiniJSON;
using System.Linq;
using JsonDict = System.Collections.Generic.IDictionary<string, object>;
using System;

namespace Blazor.Compiler
{
Expand Down Expand Up @@ -80,7 +81,20 @@ public static string[] FindReferencedAssemblies(string copyFromProjectRoot, Opti
return Enumerable.Empty<string>();
});

return referenceAssemblies.Select(path => path.Replace('/', Path.DirectorySeparatorChar)).ToArray();
return referenceAssemblies
.Select(path => path.Replace('/', Path.DirectorySeparatorChar))
.Distinct(new FilenameComparer()) // TODO: Make sure you pick the most recent version of each assembly, not just an arbitrary one
.ToArray();
}

private class FilenameComparer : IEqualityComparer<string>
{
public bool Equals(string x, string y) => string.Equals(
Path.GetFileName(x),
Path.GetFileName(y),
StringComparison.OrdinalIgnoreCase);

public int GetHashCode(string obj) => Path.GetFileName(obj).ToLowerInvariant().GetHashCode();
}
}
}

0 comments on commit 594307c

Please sign in to comment.