// TODO (tomat): use AssemblyIdentity.GetBestMatch private static AssemblyIdentity FindHighestVersionOrFirstMatchingIdentity(string name, IEnumerable <AssemblyIdentity> identities) { // Name can be partial or full. In both cases multiple assemblies might match. // If the name is partial and doesn't specify version we pick the highest available version. AssemblyIdentity candidateIdentity = null; foreach (var identity in identities) { if (AssemblyIdentity.ReferenceMatchesDefinition(name, identity)) { if (candidateIdentity == null || candidateIdentity.Version < identity.Version) { candidateIdentity = identity; } } } return(candidateIdentity); }