private static ICollection <PackageReference> GetPackageReferences(string fullConfigFilePath, string projectName) { var projectFileSystem = new PhysicalFileSystem(Path.GetDirectoryName(fullConfigFilePath)); string configFileName = Path.GetFileName(fullConfigFilePath); PackageReferenceFile file = new PackageReferenceFile(projectFileSystem, configFileName, projectName); return(CommandLineUtility.GetPackageReferences(file, requireVersion: true)); }
private void InstallPackagesFromConfigFile(IFileSystem fileSystem, PackageReferenceFile file, string fileName) { var packageReferences = CommandLineUtility.GetPackageReferences(file, fileName, requireVersion: true); bool installedAny = ExecuteInParallel(fileSystem, packageReferences); if (!installedAny && packageReferences.Any()) { Console.WriteLine(NuGetResources.InstallCommandNothingToInstall, Constants.PackageReferenceFile); } }
private IEnumerable <PackageReference> GetPackagesToMirror(string packageId, bool isConfigFile) { if (isConfigFile) { IFileSystem fileSystem = CreateFileSystem(); string configFilePath = Path.GetFullPath(packageId); var packageReferenceFile = GetPackageReferenceFile(fileSystem, configFilePath); return(CommandLineUtility.GetPackageReferences(packageReferenceFile, requireVersion: false)); } return(new[] { new PackageReference(packageId, GetVersion(), versionConstraint: null, targetFramework: null, isDevelopmentDependency: false) }); }
private void InstallPackagesFromConfigFile(IFileSystem fileSystem, PackageReferenceFile configFile) { // display opt-out message if needed if (Console != null && RequireConsent && new PackageRestoreConsent(Settings).IsGranted) { string message = LocalizedResourceManager.RestoreCommandPackageRestoreOptOutMessage; Console.WriteLine(message); } var packageReferences = CommandLineUtility.GetPackageReferences(configFile, requireVersion: true); bool installedAny = ExecuteInParallel(fileSystem, packageReferences); if (!installedAny && packageReferences.Any()) { Console.WriteLine(LocalizedResourceManager.GetString("InstallCommandNothingToInstall"), Constants.PackageReferenceFile); } }
private static ICollection <PackageReference> GetPackageReferencesInDirectory(string directory) { var packageReferences = new HashSet <PackageReference>(); 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 { packageReferences.AddRange(CommandLineUtility.GetPackageReferences(file, requireVersion: true)); } catch (InvalidOperationException) { // Skip the file if it is not a valid xml file. } } return(packageReferences); }