Esempio n. 1
0
        public async Task Install(IReadOnlyList <SourceRepository> remoteRepositories, NuGetPackageManager packageManager)
        {
            if (_versionMatch == null)
            {
                return;
            }
            IReadOnlyList <SourceRepository> sourceRepositories = GetSourceRepositories(remoteRepositories);

            using (Trace.WithIndent().Verbose($"Installing package {_packageId} {_versionMatch.Version}"))
            {
                ResolutionContext resolutionContext = new ResolutionContext(
                    DependencyBehavior.Lowest, _allowPrereleaseVersions, _allowUnlisted, VersionConstraints.None);
                INuGetProjectContext projectContext = new NuGetProjectContext();
                await packageManager.InstallPackageAsync(packageManager.PackagesFolderNuGetProject,
                                                         new PackageIdentity(_packageId, _versionMatch), resolutionContext, projectContext,
                                                         sourceRepositories, Array.Empty <SourceRepository>(), CancellationToken.None);

                Trace.Verbose($"Installed package {_packageId} {_versionMatch.Version}");
            }
        }
Esempio n. 2
0
        public async Task Install(IReadOnlyList <SourceRepository> remoteRepositories, InstalledPackagesCache installedPackages, NuGetPackageManager packageManager)
        {
            if (_versionMatch == null)
            {
                return;
            }
            IReadOnlyList <SourceRepository> sourceRepositories = GetSourceRepositories(remoteRepositories);

            using (Trace.WithIndent().Verbose($"Installing package {_packageId} {_versionMatch.ToNormalizedString()}"))
            {
                // Check if this package was already installed in a previous run
                PackageIdentity packageIdentity = new PackageIdentity(_packageId, _versionMatch);
                if (installedPackages.VerifyPackage(packageIdentity, packageManager))
                {
                    Trace.Verbose($"Package {_packageId} {_versionMatch.ToNormalizedString()} was already installed");
                    return;
                }

                // If not, go ahead and install it
                using (installedPackages.AddPackage(packageIdentity, _currentFramework))
                {
                    ResolutionContext resolutionContext = new ResolutionContext(
                        DependencyBehavior.Lowest, _allowPrereleaseVersions, _allowUnlisted, VersionConstraints.None);
                    INuGetProjectContext projectContext = new NuGetProjectContext();
                    await packageManager.InstallPackageAsync(
                        packageManager.PackagesFolderNuGetProject,
                        packageIdentity,
                        resolutionContext,
                        projectContext,
                        sourceRepositories,
                        Array.Empty <SourceRepository>(),
                        CancellationToken.None);

                    Trace.Verbose($"Installed package {_packageId} {_versionMatch.ToNormalizedString()}");
                }
            }
        }
Esempio n. 3
0
 public async Task Install(IReadOnlyList<SourceRepository> remoteRepositories, NuGetPackageManager packageManager)
 {
     if (_versionMatch == null)
     {
         return;
     }
     IReadOnlyList<SourceRepository> sourceRepositories = GetSourceRepositories(remoteRepositories);
     Trace.Verbose($"Installing package {_packageId} {_versionMatch.Version}");
     ResolutionContext resolutionContext = new ResolutionContext(
         DependencyBehavior.Lowest, _allowPrereleaseVersions, _allowUnlisted, VersionConstraints.None);
     INuGetProjectContext projectContext = new NuGetProjectContext();
     await packageManager.InstallPackageAsync(packageManager.PackagesFolderNuGetProject,
         new PackageIdentity(_packageId, _versionMatch), resolutionContext, projectContext, sourceRepositories,
         Array.Empty<SourceRepository>(), CancellationToken.None);
     Trace.Verbose($"Installed package {_packageId} {_versionMatch.Version}");
 }