/// <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()));
        }
Esempio n. 2
0
        public override IEnumerable <LocalPackageInfo> GetPackages(ILogger logger, CancellationToken cancellationToken)
        {
            if (_delay.HasValue)
            {
                // intentional delay
                Thread.Sleep(_delay.Value);
            }

            var packages = LocalFolderUtility.GetPackagesV2(Root, logger, cancellationToken);

            // Filter out any duplicates that may appear in the folder multiple times.
            return(LocalFolderUtility.GetDistinctPackages(packages));
        }
Esempio n. 3
0
        /// <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()));
        }