private IEnumerable<string> GetPackageAssemblyNames(string path) { var compatibilityProvider = new DefaultCompatibilityProvider(); var folderReader = new PackageFolderReader(Path.Combine(path, _fileSystem.PackagesFolder)); var nupkgFiles = folderReader.GetFiles().Where(x => Path.GetExtension(x).ToLowerInvariant() == ".nupkg"); var packagesConfig = XDocument.Parse(File.ReadAllText(Path.Combine(path, _fileSystem.PackagesFile))); var reader = new PackagesConfigReader(packagesConfig); var contents = reader.GetPackages(); var result = new List<string>(); foreach (var nupkg in nupkgFiles) { var stream = folderReader.GetStream(nupkg); var packageReader = new PackageReader(stream); var identity = packageReader.GetIdentity(); var packagesConfigReference = contents.FirstOrDefault(x => x.PackageIdentity.Id == identity.Id && x.PackageIdentity.Version == identity.Version); if (packagesConfigReference == null) { break; } var packageContents = packageReader.GetLibItems().Where(x => compatibilityProvider.IsCompatible(x.TargetFramework, packagesConfigReference.TargetFramework)). SelectMany(x => x.Items.Where(i => Path.GetExtension(i).ToLowerInvariant() == ".dll")); result.AddRange(packageContents); } return result; }
private static CommandSpec ConfigureCommandFromPackage(string commandName, IEnumerable<string> args, string packageDir) { var commandPackage = new PackageFolderReader(packageDir); var files = commandPackage.GetFiles(); return ConfigureCommandFromPackage(commandName, args, files, packageDir); }