Created
March 5, 2013 03:40
-
-
Save filipw/5087814 to your computer and use it in GitHub Desktop.
Get relevant assemblies with Nuget.Core
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IEnumerable<string> GetAssemblyNames(List<string> packageids, string version) | |
{ | |
var packageDir = _fileSystem.CurrentDirectory + @"\" + "packages"; | |
if (!Directory.Exists(packageDir)) | |
return Enumerable.Empty<string>(); | |
var items = new List<string>(); | |
var repository = new LocalPackageRepository(packageDir); | |
var pcskg = repository.FindPackages(packageids); | |
foreach (var package in pcskg) | |
{ | |
IEnumerable<IPackageFile> packageFiles; | |
VersionUtility.TryGetCompatibleItems(VersionUtility.ParseFrameworkFolderName(version), package.GetLibFiles().Where(i => i.Path.Contains(".dll")), out packageFiles); | |
if (packageFiles != null) | |
{ | |
foreach (var packageFile in packageFiles) | |
{ | |
var path = packageDir + "\\" + package.Id +"."+package.Version + "\\" + packageFile.Path; | |
Console.WriteLine("Found package reference: " + path); | |
items.Add(path); | |
} | |
} | |
} | |
return items; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment