/// <summary> /// Asynchronously gets installed packages. /// </summary> /// <remarks>This is used only for the install command, not in PM.</remarks> /// <param name="token">A cancellation token.</param> /// <returns>A task that represents the asynchronous operation. /// The task result (<see cref="Task{TResult}.Result" />) returns an /// <see cref="IEnumerable{PackageReference}" />.</returns> public Task <IEnumerable <PackageReference> > GetFolderPackagesAsync(CancellationToken token) { token.ThrowIfCancellationRequested(); var packages = Enumerable.Empty <LocalPackageInfo>(); if (Directory.Exists(Root)) { if (_packagePathResolver.UseSideBySidePaths) { // Id.Version packages = LocalFolderUtility.GetPackagesConfigFolderPackages(Root, NullLogger.Instance); } else { // Id // Ignore packages that are in SxS or a different format. packages = LocalFolderUtility.GetPackagesV2(Root, NullLogger.Instance, token) .Where(PackageIsValidForPathResolver); } } return(Task.FromResult <IEnumerable <PackageReference> >( LocalFolderUtility.GetDistinctPackages(packages) .Select(e => new PackageReference(e.Identity, _framework)) .ToList())); }
/// <summary> /// Asynchronously gets installed packages. /// </summary> /// <remarks>This is used only for the install command, not in PM.</remarks> /// <param name="token">A cancellation token.</param> /// <returns>A task that represents the asynchronous operation. /// The task result (<see cref="Task{TResult}.Result" />) returns an /// <see cref="IEnumerable{PackageReference}" />.</returns> public Task <IEnumerable <PackageReference> > GetFolderPackagesAsync(CancellationToken token) { var packages = Enumerable.Empty <LocalPackageInfo>(); if (Directory.Exists(Root)) { if (_packagePathResolver.UseSideBySidePaths) { // Id.Version packages = LocalFolderUtility.GetPackagesConfigFolderPackages(Root, NullLogger.Instance); } else { // Id packages = LocalFolderUtility.GetPackagesV2(Root, NullLogger.Instance); } } return(Task.FromResult <IEnumerable <PackageReference> >( LocalFolderUtility.GetDistinctPackages(packages) .Select(e => new PackageReference(e.Identity, _framework)) .ToList())); }