private static ICollection <InstalledPackageReference> GetInstalledPackageReferences(string fullConfigFilePath, string projectName) { var projectFileSystem = new PhysicalFileSystem(Path.GetDirectoryName(fullConfigFilePath)); string configFileName = Path.GetFileName(fullConfigFilePath); PackageReferenceFile packageReferenceFile = new PackageReferenceFile(projectFileSystem, configFileName, projectName); return(CommandLineUtility.GetInstalledPackageReferences(packageReferenceFile, requireVersion: true)); }
private static ICollection <InstalledPackageReference> GetInstalledPackageReferencesInDirectory(string directory) { var installedPackageReferences = new HashSet <InstalledPackageReference>(); var configFiles = Directory.GetFiles(directory, "packages*.config", SearchOption.AllDirectories) .Where(f => Path.GetFileName(f).StartsWith("packages.", StringComparison.OrdinalIgnoreCase)); foreach (var configFile in configFiles) { PackageReferenceFile file = new PackageReferenceFile(configFile); try { installedPackageReferences.AddRange(CommandLineUtility.GetInstalledPackageReferences(file, requireVersion: true)); } catch (InvalidOperationException) { // Skip the file if it is not a valid xml file. } } return(installedPackageReferences); }