public ProjectTemplateSourceRepositoryProvider()
        {
            provider = SourceRepositoryProviderFactory.CreateSourceRepositoryProvider();
            var packageSource = new PackageSource(NuGetConstants.V3FeedUrl);

            nugetSourceRepository = provider.CreateRepository(packageSource);
        }
Esempio n. 2
0
        public void InstallPackages(
            Project project,
            IEnumerable <PackageManagementPackageReference> packages)
        {
            var repositoryProvider = SourceRepositoryProviderFactory.CreateSourceRepositoryProvider();
            var repositories       = repositoryProvider.GetRepositories().ToList();

            InstallPackages(repositories, project, packages, licensesAccepted: false);
        }
Esempio n. 3
0
        internal IEnumerable <INuGetPackageAction> CreateInstallActions(
            string packageSourceUrl,
            Project project,
            IEnumerable <PackageManagementPackageReference> packages)
        {
            var repositoryProvider = SourceRepositoryProviderFactory.CreateSourceRepositoryProvider();
            var repository         = repositoryProvider.CreateRepository(new PackageSource(packageSourceUrl));

            return(CreateInstallActions(new [] { repository }, project, packages, false));
        }
Esempio n. 4
0
        public void InstallPackages(
            string packageSourceUrl,
            Project project,
            IEnumerable <PackageManagementPackageReference> packages,
            bool licensesAccepted)
        {
            var repositoryProvider = SourceRepositoryProviderFactory.CreateSourceRepositoryProvider();
            var repository         = repositoryProvider.CreateRepository(new PackageSource(packageSourceUrl));

            InstallPackages(new [] { repository }, project, packages, licensesAccepted);
        }
        /// <summary>
        /// Installs NuGet packages into the selected project using the enabled package sources.
        /// </summary>
        /// <param name="project">Project.</param>
        /// <param name="packages">Packages.</param>
        public Task InstallPackagesAsync(Project project, IEnumerable <PackageManagementPackageReference> packages)
        {
            var repositoryProvider = SourceRepositoryProviderFactory.CreateSourceRepositoryProvider();
            var repositories       = repositoryProvider.GetRepositories().ToList();

            var actions = CreateInstallActions(repositories, project, packages, licensesAccepted: false).ToList();

            ProgressMonitorStatusMessage progressMessage = GetInstallingStatusMessages(actions);

            return(backgroundActionRunner.RunAsync(progressMessage, actions));
        }
        async Task <List <InstallNuGetPackageAction> > CreatePackageActions(DotNetProject project, IEnumerable <TemplatePackageReference> packageReferences)
        {
            var repositoryProvider = SourceRepositoryProviderFactory.CreateSourceRepositoryProvider();
            var repositories       = repositoryProvider.GetRepositories().ToList();
            var solutionManager    = PackageManagementServices.Workspace.GetSolutionManager(project.ParentSolution);

            var installPackageActions = new List <InstallNuGetPackageAction> ();

            var context = new NuGetProjectContext(solutionManager.Settings)
            {
                FileConflictResolution = FileConflictAction.IgnoreAll
            };

            var dotNetProject     = new DotNetProjectProxy(project);
            var nugetProject      = solutionManager.GetNuGetProject(dotNetProject);
            var installedPackages = (await nugetProject.GetInstalledPackagesAsync(CancellationToken.None)).ToList();

            foreach (var packageReference in packageReferences)
            {
                var version = new NuGetVersion(packageReference.Version);

                if (!ShouldInstallPackage(packageReference.Id, version, installedPackages))
                {
                    continue;
                }

                var action = new InstallNuGetPackageAction(
                    repositories,
                    solutionManager,
                    dotNetProject,
                    context)
                {
                    LicensesMustBeAccepted = false,
                    OpenReadmeFile         = false,
                    PackageId = packageReference.Id,
                    Version   = version
                };

                installPackageActions.Add(action);
            }

            return(installPackageActions);
        }
 public ISourceRepositoryProvider CreateSourceRepositoryProvider()
 {
     return(SourceRepositoryProviderFactory.CreateSourceRepositoryProvider(Settings));
 }