/// <summary> /// Initializes a new <see cref="LocalV2FindPackageByIdResource" /> class. /// </summary> /// <param name="packageSource">A package source.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="packageSource" /> /// is <c>null</c>.</exception> public LocalV2FindPackageByIdResource(PackageSource packageSource) { if (packageSource == null) { throw new ArgumentNullException(nameof(packageSource)); } var rootDirInfo = LocalFolderUtility.GetAndVerifyRootDirectory(packageSource.Source); _source = rootDirInfo.FullName; }
public LocalV3FindPackageByIdResource(PackageSource source) { if (source == null) { throw new ArgumentNullException(nameof(source)); } var rootDirInfo = LocalFolderUtility.GetAndVerifyRootDirectory(source.Source); _source = rootDirInfo.FullName; _resolver = new VersionFolderPathResolver(_source); }
private static IReadOnlyList <LocalPackageInfo> GetPackagesCore(string root) { var rootDirInfo = LocalFolderUtility.GetAndVerifyRootDirectory(root); if (!rootDirInfo.Exists) { return(new List <LocalPackageInfo>()); } var files = rootDirInfo.GetFiles("*" + PackagingCoreConstants.NupkgExtension, SearchOption.TopDirectoryOnly); var directories = rootDirInfo.GetDirectories("*", SearchOption.TopDirectoryOnly); // Find all packages that have both a nupkg and a directory var validSet = new HashSet <string>(directories.Select(dir => dir.Name), StringComparer.OrdinalIgnoreCase); validSet.IntersectWith(files.Select(file => Path.GetFileNameWithoutExtension(file.Name))); var result = new List <LocalPackageInfo>(validSet.Count); foreach (var name in validSet) { var nuspec = GetNuspec(rootDirInfo, name); var nupkgPath = Path.Combine(rootDirInfo.FullName, $"{name}{PackagingCoreConstants.NupkgExtension}"); var localPackage = new LocalPackageInfo( nuspec.GetIdentity(), nupkgPath, DateTime.UtcNow, new Lazy <NuspecReader>(() => nuspec), useFolder: true ); result.Add(localPackage); } return(result); }
public LocalV2FindPackageByIdResource(PackageSource packageSource) { var rootDirInfo = LocalFolderUtility.GetAndVerifyRootDirectory(packageSource.Source); _source = rootDirInfo.FullName; }