Skip to content

Instantly share code, notes, and snippets.

@filipw
Created March 5, 2013 03:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save filipw/5087814 to your computer and use it in GitHub Desktop.
Save filipw/5087814 to your computer and use it in GitHub Desktop.
Get relevant assemblies with Nuget.Core
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