Exemple #1
0
        InstallNuGetPackageAction CreateInstallNuGetPackageAction(
            DotNetProject dotNetProject,
            ProjectTemplateSourceRepositoryProvider repositoryProvider,
            ProjectTemplatePackageReference packageReference)
        {
            var primaryRepositories   = repositoryProvider.GetRepositories(packageReference).ToList();
            var secondaryRepositories = GetSecondaryRepositories(primaryRepositories, packageReference);
            var solutionManager       = PackageManagementServices.Workspace.GetSolutionManager(dotNetProject.ParentSolution);

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

            return(new InstallNuGetPackageAction(
                       primaryRepositories,
                       secondaryRepositories,
                       solutionManager,
                       new DotNetProjectProxy(dotNetProject),
                       context)
            {
                LicensesMustBeAccepted = packageReference.RequireLicenseAcceptance,
                OpenReadmeFile = false
            });
        }
Exemple #2
0
 NuGetVersion GetPackageVersion(ProjectTemplatePackageReference packageReference)
 {
     if (!string.IsNullOrEmpty(packageReference.Version))
     {
         return(new NuGetVersion(packageReference.Version));
     }
     return(null);
 }
Exemple #3
0
 /// <summary>
 /// If the package is a local package then we prevent NuGet from using online package sources
 /// defined in the NuGet.Config file by using the returning the primaryRepositories.
 /// Returning null allows all enabled package sources to be used when resolving dependencies.
 /// </summary>
 static IEnumerable <SourceRepository> GetSecondaryRepositories(
     IEnumerable <SourceRepository> primaryRepositories, ProjectTemplatePackageReference packageReference)
 {
     if (packageReference.IsLocalPackage || packageReference.Directory.IsNotNull)
     {
         return(primaryRepositories);
     }
     return(null);
 }
Exemple #4
0
        InstallNuGetPackageAction CreateInstallNuGetPackageAction(
            DotNetProject dotNetProject,
            ProjectTemplateSourceRepositoryProvider repositoryProvider,
            ProjectTemplatePackageReference packageReference)
        {
            var primaryRepositories   = repositoryProvider.GetRepositories(packageReference.IsLocalPackage);
            var secondaryRepositories = GetSecondaryRepositories(primaryRepositories, packageReference.IsLocalPackage);

            return(new InstallNuGetPackageAction(
                       primaryRepositories,
                       secondaryRepositories,
                       PackageManagementServices.Workspace.GetSolutionManager(dotNetProject.ParentSolution),
                       new DotNetProjectProxy(dotNetProject),
                       new NuGetProjectContext()));
        }
        public IEnumerable <SourceRepository> GetRepositories(ProjectTemplatePackageReference packageReference)
        {
            if (packageReference.Directory.IsNotNull)
            {
                yield return(CreateRepository(packageReference.Directory));

                yield break;
            }

            foreach (SourceRepository sourceRepository in GetProjectTemplateRepositories())
            {
                if (!packageReference.IsLocalPackage || sourceRepository.PackageSource.IsLocal)
                {
                    yield return(sourceRepository);
                }
            }

            if (!packageReference.IsLocalPackage)
            {
                yield return(nugetSourceRepository);
            }
        }