Exemplo n.º 1
0
        public void CreateSharedRepository_MethodCalled_ReturnsSharedPackageRepository()
        {
            CreateCache();
            ISharedPackageRepository repository = cache.CreateSharedRepository(null, null, null);

            Assert.IsNotNull(repository);
        }
Exemplo n.º 2
0
        private void RegisterPackagesConfig(ISharedPackageRepository sharedPackagesRepository)
        {
            var packagesConfigFilePath = Path.Combine(_vsProject.ProjectDirectory.FullName + "\\", PackageReferenceFilename);

            sharedPackagesRepository.RegisterRepository(packagesConfigFilePath);
            _vsProject.AddFile(PackageReferenceFilename);
        }
Exemplo n.º 3
0
        public PackageManager(IPackageRepository sourceRepository, IPackagePathResolver pathResolver, IFileSystem fileSystem, ISharedPackageRepository localRepository)
        {
            if (sourceRepository == null)
            {
                throw new ArgumentNullException("sourceRepository");
            }
            if (pathResolver == null)
            {
                throw new ArgumentNullException("pathResolver");
            }
            if (fileSystem == null)
            {
                throw new ArgumentNullException("fileSystem");
            }
            if (localRepository == null)
            {
                throw new ArgumentNullException("localRepository");
            }

            SourceRepository  = sourceRepository;
            PathResolver      = pathResolver;
            FileSystem        = fileSystem;
            LocalRepository   = localRepository;
            DependencyVersion = DependencyVersion.Lowest;
            CheckDowngrade    = true;
        }
Exemplo n.º 4
0
 public RepositoryInfo(string path, string configFolderPath, IFileSystem fileSystem, ISharedPackageRepository repository)
 {
     Path             = path;
     FileSystem       = fileSystem;
     Repository       = repository;
     ConfigFolderPath = configFolderPath;
 }
 public void AddNugetReferenceMetadata(ISharedPackageRepository sharedPackagesRepository, ICollection<IPackage> packagesToAdd)
 {
     _console.WriteLine("Checking for any project references for {0}...", PackageReferenceFilename);
     if (!packagesToAdd.Any()) return;
     CreatePackagesConfig(packagesToAdd);
     RegisterPackagesConfig(sharedPackagesRepository);
 }
 public MockVsPackageManager(
     ISolutionManager solutionManager,
     IPackageRepository sourceRepository,
     ISharedPackageRepository localRepository)
     : base(solutionManager, sourceRepository, new Mock <IFileSystemProvider>().Object, new MockFileSystem("x:\\root"), localRepository, new Mock <IDeleteOnRestartManager>().Object, new Mock <VsPackageInstallerEvents>().Object)
 {
 }
Exemplo n.º 7
0
        public PackageManager(
            IPackageRepository sourceRepository, 
            IPackagePathResolver pathResolver, 
            IFileSystem fileSystem, 
            ISharedPackageRepository localRepository)
        {
            if (sourceRepository == null)
            {
                throw new ArgumentNullException("sourceRepository");
            }
            if (pathResolver == null)
            {
                throw new ArgumentNullException("pathResolver");
            }
            if (fileSystem == null)
            {
                throw new ArgumentNullException("fileSystem");
            }
            if (localRepository == null)
            {
                throw new ArgumentNullException("localRepository");
            }

            SourceRepository = sourceRepository;
            DependencyResolver = new DependencyResolverFromRepo(sourceRepository);
            PathResolver = pathResolver;
            FileSystem = fileSystem;
            LocalRepository = localRepository;
            DependencyVersion = DependencyVersion.Lowest;
            CheckDowngrade = true;
        }
Exemplo n.º 8
0
        internal void UpdatePackages(IPackageRepository localRepository,
                                     IFileSystem sharedRepositoryFileSystem,
                                     ISharedPackageRepository sharedPackageRepository,
                                     IPackageRepository sourceRepository,
                                     IPackageConstraintProvider constraintProvider,
                                     IPackagePathResolver pathResolver,
                                     IProjectSystem project)
        {
            var packageManager = new PackageManager(sourceRepository, pathResolver, sharedRepositoryFileSystem, sharedPackageRepository);

            var projectManager = new ProjectManager(sourceRepository, pathResolver, project, localRepository)
            {
                ConstraintProvider = constraintProvider
            };

            // Fix for work item 2411: When updating packages, we did not add packages to the shared package repository.
            // Consequently, when querying the package reference repository, we would have package references with no backing package files in
            // the shared repository. This would cause the reference repository to skip the package assuming that the entry is invalid.
            projectManager.PackageReferenceAdded += (sender, eventArgs) =>
            {
                PackageExtractor.InstallPackage(packageManager, eventArgs.Package);
            };

            projectManager.Logger = project.Logger = new VerboseLogger(this);

            using (sourceRepository.StartOperation(RepositoryOperationNames.Update))
            {
                foreach (var package in GetPackages(localRepository))
                {
                    if (localRepository.Exists(package.Id))
                    {
                        try
                        {
                            if (projectManager.IsInstalled(package))
                            {
                                Log(Level.Debug, "Found installed package {0}", package.Id);
                            }
                            // If the user explicitly allows prerelease or if the package being updated is prerelease we'll include prerelease versions in our list of packages
                            // being considered for an update.
                            bool allowPrerelease = Prerelease || !package.IsReleaseVersion();
                            if (Safe)
                            {
                                IVersionSpec safeRange = VersionUtility.GetSafeRange(package.Version);
                                projectManager.UpdatePackageReference(package.Id, safeRange, updateDependencies: true, allowPrereleaseVersions: allowPrerelease);
                            }
                            else
                            {
                                projectManager.UpdatePackageReference(package.Id, version: null, updateDependencies: true, allowPrereleaseVersions: allowPrerelease);
                            }
                        }
                        catch (InvalidOperationException e)
                        {
                            Log(Level.Warning, e.Message);
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
        public void CreatePackageManager_ProjectAndSolutionHaveDifferentFolders_PackageManagerLocalRepositoryIsSharedRepository()
        {
            CreateFactory();
            CreateTestProject();
            CreatePackageManager();
            ISharedPackageRepository sharedRepository = packageManager.LocalRepository as ISharedPackageRepository;

            Assert.IsNotNull(sharedRepository);
        }
Exemplo n.º 10
0
        public VsPackageManager(ISolutionManager solutionManager, IPackageRepository sourceRepository, IFileSystem fileSystem, ISharedPackageRepository sharedRepository, IPackageRepository recentPackagesRepository) :
            base(sourceRepository, new DefaultPackagePathResolver(fileSystem), fileSystem, sharedRepository)
        {
            _solutionManager          = solutionManager;
            _sharedRepository         = sharedRepository;
            _recentPackagesRepository = recentPackagesRepository;

            _projects = new Dictionary <string, IProjectManager>(StringComparer.OrdinalIgnoreCase);
        }
Exemplo n.º 11
0
 public CoreInteropPackageManager(
     ISharedPackageRepository sharedRepo,
     IDependencyResolver2 dependencyResolver,
     CoreInteropSourceRepository sourceRepo)
 {
     _sharedRepo        = sharedRepo;
     _sourceRepo        = sourceRepo;
     DependencyResolver = dependencyResolver;
 }
Exemplo n.º 12
0
 public CoreInteropPackageManager(
     ISharedPackageRepository sharedRepo,
     IDependencyResolver2 dependencyResolver,
     CoreInteropSourceRepository sourceRepo)
 {
     _sharedRepo = sharedRepo;
     _sourceRepo = sourceRepo;
     DependencyResolver = dependencyResolver;
 }
Exemplo n.º 13
0
        public VsPackageManager(ISolutionManager solutionManager, IPackageRepository sourceRepository, IFileSystem fileSystem, ISharedPackageRepository sharedRepository, IPackageRepository recentPackagesRepository)
            : base(sourceRepository, new DefaultPackagePathResolver(fileSystem), fileSystem, sharedRepository)
        {
            _solutionManager = solutionManager;
            _sharedRepository = sharedRepository;
            _recentPackagesRepository = recentPackagesRepository;

            _projects = new Dictionary<string, IProjectManager>(StringComparer.OrdinalIgnoreCase);
        }
Exemplo n.º 14
0
 public void AddNugetReferenceMetadata(ISharedPackageRepository sharedPackagesRepository, ICollection <IPackage> packagesToAdd, FrameworkName targetFramework)
 {
     _console.WriteLine("Checking for any project references for {0}...", PackageReferenceFilename);
     if (!packagesToAdd.Any())
     {
         return;
     }
     CreatePackagesConfig(packagesToAdd, targetFramework);
     RegisterPackagesConfig(sharedPackagesRepository);
 }
Exemplo n.º 15
0
        ISharpDevelopPackageManager CreatePackageManager(
            IFileSystem fileSystem,
            IPackageRepository packageRepository,
            MSBuildBasedProject project)
        {
            DefaultPackagePathResolver pathResolver     = new DefaultPackagePathResolver(fileSystem);
            ISharedPackageRepository   sharedRepository = CreateSharedRepository(pathResolver, fileSystem);
            IProjectSystem             projectSystem    = CreateProjectSystem(project);

            return(new SharpDevelopPackageManager(packageRepository, projectSystem, fileSystem, sharedRepository, pathResolver));
        }
Exemplo n.º 16
0
 public PackageReferenceRepository(string configFilePath, ISharedPackageRepository sourceRepository)
 {
     if (string.IsNullOrEmpty(configFilePath))
     {
         throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "configFilePath");
     }
     if (sourceRepository == null)
     {
         throw new ArgumentNullException("sourceRepository");
     }
     this._packageReferenceFile = new PackageReferenceFile(configFilePath);
     this.SourceRepository      = sourceRepository;
 }
Exemplo n.º 17
0
 public PackageReferenceRepository(IFileSystem fileSystem, ISharedPackageRepository sourceRepository)
 {
     if (fileSystem == null)
     {
         throw new ArgumentNullException("fileSystem");
     }
     if (sourceRepository == null)
     {
         throw new ArgumentNullException("sourceRepository");
     }
     _packageReferenceFile = new PackageReferenceFile(fileSystem, PackageReferenceFile);
     _fullPath             = fileSystem.GetFullPath(PackageReferenceFile);
     SourceRepository      = sourceRepository;
 }
Exemplo n.º 18
0
 public PackageReferenceRepository(IFileSystem fileSystem, ISharedPackageRepository sourceRepository)
 {
     if (fileSystem == null)
     {
         throw new ArgumentNullException("fileSystem");
     }
     if (sourceRepository == null)
     {
         throw new ArgumentNullException("sourceRepository");
     }
     _packageReferenceFile = new PackageReferenceFile(fileSystem, Constants.PackageReferenceFile);
     _fullPath = fileSystem.GetFullPath(Constants.PackageReferenceFile);
     SourceRepository = sourceRepository;
 }
		public SharpDevelopPackageManager(
			IPackageRepository sourceRepository,
			IProjectSystem projectSystem,
			IFileSystem fileSystem,
			ISharedPackageRepository localRepository,
			IPackagePathResolver pathResolver)
			: base(
				sourceRepository,
				pathResolver,
				fileSystem,
				localRepository)
		{
			this.projectSystem = projectSystem;
			CreateProjectManager();
		}
 public SharpDevelopPackageManager(
     IPackageRepository sourceRepository,
     IProjectSystem projectSystem,
     IFileSystem fileSystem,
     ISharedPackageRepository localRepository,
     IPackagePathResolver pathResolver)
     : base(
         sourceRepository,
         pathResolver,
         fileSystem,
         localRepository)
 {
     this.projectSystem = projectSystem;
     CreateProjectManager();
 }
Exemplo n.º 21
0
        public VsPackageManager(ISolutionManager solutionManager,
                IPackageRepository sourceRepository,
                IFileSystemProvider fileSystemProvider,
                IFileSystem fileSystem,
                ISharedPackageRepository sharedRepository,
                IDeleteOnRestartManager deleteOnRestartManager,
                VsPackageInstallerEvents packageEvents)
            : base(sourceRepository, new DefaultPackagePathResolver(fileSystem), fileSystem, sharedRepository)
        {
            _solutionManager = solutionManager;
            _sharedRepository = sharedRepository;
            _packageEvents = packageEvents;
            _fileSystemProvider = fileSystemProvider;
            _deleteOnRestartManager = deleteOnRestartManager;

            _projects = new Dictionary<string, IProjectManager>(StringComparer.OrdinalIgnoreCase);
        }
        public CoreInteropProjectManager(
            InstallationTarget target,
            SourceRepository activeSource,
            IDependencyResolver2 dependencyResolver)
        {
            // Get the required features from the target
            _sharedRepo    = target.GetRequiredFeature <ISharedPackageRepository>();
            _refRepo       = target.GetRequiredFeature <IProjectManager>().LocalRepository;
            _projectSystem = target.TryGetFeature <IProjectSystem>();
            _target        = target;

            _sourceRepo = new CoreInteropSourceRepository(activeSource);
            _pacman     = new CoreInteropPackageManager(
                _sharedRepo,
                dependencyResolver,
                _sourceRepo);
        }
Exemplo n.º 23
0
        public PackageReferenceRepository(
            string configFilePath,
            ISharedPackageRepository sourceRepository)
        {
            if (String.IsNullOrEmpty(configFilePath))
            {
                throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "configFilePath");
            }

            if (sourceRepository == null)
            {
                throw new ArgumentNullException("sourceRepository");
            }

            _packageReferenceFile = new PackageReferenceFile(configFilePath);
            SourceRepository = sourceRepository;
        }
Exemplo n.º 24
0
        public CoreInteropProjectManager(
            InstallationTarget target, 
            SourceRepository activeSource,
            IDependencyResolver2 dependencyResolver)
        {
            // Get the required features from the target
            _sharedRepo = target.GetRequiredFeature<ISharedPackageRepository>();
            _refRepo = target.GetRequiredFeature<IProjectManager>().LocalRepository;
            _projectSystem = target.TryGetFeature<IProjectSystem>();
            _target = target;

            _sourceRepo = new CoreInteropSourceRepository(activeSource);
            _pacman = new CoreInteropPackageManager(
                _sharedRepo,
                dependencyResolver,
                _sourceRepo);
        }
 public VsPackageManager(ISolutionManager solutionManager,
         IPackageRepository sourceRepository,
         IFileSystemProvider fileSystemProvider,
         IFileSystem fileSystem,
         ISharedPackageRepository sharedRepository,
         IDeleteOnRestartManager deleteOnRestartManager,
         VsPackageInstallerEvents packageEvents,
         IVsFrameworkMultiTargeting frameworkMultiTargeting = null)
     : base(sourceRepository, new DefaultPackagePathResolver(fileSystem), fileSystem, sharedRepository)
 {
     _solutionManager = solutionManager;
     _sharedRepository = sharedRepository;
     _packageEvents = packageEvents;
     _fileSystemProvider = fileSystemProvider;
     _deleteOnRestartManager = deleteOnRestartManager;
     _frameworkMultiTargeting = frameworkMultiTargeting;
     _projects = new Dictionary<string, IProjectManager>(StringComparer.OrdinalIgnoreCase);
 }
Exemplo n.º 26
0
        public PackageReferenceRepository(
            IFileSystem fileSystem, 
            string projectName, 
            ISharedPackageRepository sourceRepository)
        {
            if (fileSystem == null)
            {
                throw new ArgumentNullException("fileSystem");
            }
            if (sourceRepository == null)
            {
                throw new ArgumentNullException("sourceRepository");
            }

            _packageReferenceFile = new PackageReferenceFile(
                fileSystem, Constants.PackageReferenceFile, projectName);

            SourceRepository = sourceRepository;
        }
Exemplo n.º 27
0
        public PackageReferenceRepository(
            IFileSystem fileSystem,
            string projectName,
            ISharedPackageRepository sourceRepository)
        {
            if (fileSystem == null)
            {
                throw new ArgumentNullException("fileSystem");
            }
            if (sourceRepository == null)
            {
                throw new ArgumentNullException("sourceRepository");
            }

            _packageReferenceFile = new PackageReferenceFile(
                fileSystem, Constants.PackageReferenceFile, projectName);

            SourceRepository = sourceRepository;
        }
Exemplo n.º 28
0
        internal void InstallPackages(IPackageRepository localRepository,
                                      IFileSystem sharedRepositoryFileSystem,
                                      ISharedPackageRepository sharedPackageRepository,
                                      IPackageRepository sourceRepository,
                                      IPackageConstraintProvider constraintProvider,
                                      IPackagePathResolver pathResolver,
                                      IProjectSystem project)
        {
            var packageManager = new PackageManager(sourceRepository, pathResolver, sharedRepositoryFileSystem, sharedPackageRepository);

            var projectManager = new ProjectManager(packageManager, pathResolver, project, localRepository)
            {
                ConstraintProvider = constraintProvider
            };

            // Fix for work item 2411: When updating packages, we did not add packages to the shared package repository.
            // Consequently, when querying the package reference repository, we would have package references with no backing package files in
            // the shared repository. This would cause the reference repository to skip the package assuming that the entry is invalid.
            projectManager.PackageReferenceAdded += (sender, eventArgs) =>
            {
                PackageExtractor.InstallPackage(packageManager, eventArgs.Package);
            };

            projectManager.Logger = project.Logger = this;

            bool allowPrerelease = Prerelease;
            var  resolver        = new ActionResolver()
            {
                AllowPrereleaseVersions = allowPrerelease
            };
            var installPackageUtility = new InstallPackageUtility(resolver)
            {
                AllowPrereleaseVersions = allowPrerelease,
                Safe = Safe
            };

            var operations            = installPackageUtility.ResolveActionsForInstallPackage(Id.FirstOrDefault(), Version, new[] { projectManager }, false);
            var userOperationExecutor = new ActionExecutor();

            userOperationExecutor.Execute(operations);
        }
Exemplo n.º 29
0
        internal IEnumerable <PackageDependency> GetReferences(IPackageRepository localRepository,
                                                               IFileSystem sharedRepositoryFileSystem,
                                                               ISharedPackageRepository sharedPackageRepository,
                                                               IPackageRepository sourceRepository,
                                                               IPackageConstraintProvider constraintProvider,
                                                               IPackagePathResolver pathResolver,
                                                               IProjectSystem project)
        {
            var packageManager = new PackageManager(sourceRepository, pathResolver, sharedRepositoryFileSystem, sharedPackageRepository);

            var projectManager = new ProjectManager(sourceRepository, pathResolver, project, localRepository)
            {
                ConstraintProvider = constraintProvider
            };

            // Fix for work item 2411: When updating packages, we did not add packages to the shared package repository.
            // Consequently, when querying the package reference repository, we would have package references with no backing package files in
            // the shared repository. This would cause the reference repository to skip the package assuming that the entry is invalid.
            projectManager.PackageReferenceAdded += (sender, eventArgs) =>
            {
                PackageExtractor.InstallPackage(packageManager, eventArgs.Package);
            };

            projectManager.Logger = project.Logger = new NugetUpdateTask.VerboseLogger(this);

            using (sourceRepository.StartOperation(RepositoryOperationNames.Update))
            {
                foreach (var package in GetPackages(localRepository))
                {
                    if (localRepository.Exists(package.Id))
                    {
                        if (projectManager.IsInstalled(package))
                        {
                            Log(Level.Debug, "Found installed package {0} version {1}", package.Id, package.Version);
                            yield return(new PackageDependency(package.Id, new VersionSpec(package.Version)));
                        }
                    }
                }
            }
        }
Exemplo n.º 30
0
        internal void UpdatePackages(IPackageRepository localRepository,
                                     IFileSystem sharedRepositoryFileSystem,
                                     ISharedPackageRepository sharedPackageRepository,
                                     IPackageRepository sourceRepository,
                                     IPackageConstraintProvider constraintProvider,
                                     IPackagePathResolver pathResolver,
                                     IProjectSystem projectSystem)
        {
            var packageManager = new PackageManager(sourceRepository, pathResolver, sharedRepositoryFileSystem, sharedPackageRepository);

            var projectManager = new ProjectManager(packageManager, pathResolver, projectSystem, localRepository)
            {
                ConstraintProvider = constraintProvider
            };

            // Fix for work item 2411: When updating packages, we did not add packages to the shared package repository.
            // Consequently, when querying the package reference repository, we would have package references with no backing package files in
            // the shared repository. This would cause the reference repository to skip the package assuming that the entry is invalid.
            projectManager.PackageReferenceAdded += (sender, eventArgs) =>
            {
                PackageExtractor.InstallPackage(packageManager, eventArgs.Package);
            };

            projectManager.Logger = projectSystem.Logger = this;

            foreach (var package in GetPackages(localRepository))
            {
                if (localRepository.Exists(package.Id))
                {
                    using (sourceRepository.StartOperation(RepositoryOperationNames.Update, package.Id, mainPackageVersion: null))
                    {
                        try
                        {
                            // If the user explicitly allows prerelease or if the package being updated is prerelease we'll include prerelease versions in our list of packages
                            // being considered for an update.
                            bool allowPrerelease = Prerelease || !package.IsReleaseVersion();
                            var  resolver        = new ActionResolver()
                            {
                                AllowPrereleaseVersions = allowPrerelease
                            };
                            var updateUtility = new UpdateUtility(resolver)
                            {
                                AllowPrereleaseVersions = allowPrerelease,
                                Safe = Safe
                            };

                            var operations            = updateUtility.ResolveActionsForUpdate(package.Id, null, new[] { projectManager }, false);
                            var userOperationExecutor = new ActionExecutor();
                            userOperationExecutor.Execute(operations);
                        }
                        catch (InvalidOperationException e)
                        {
                            if (Console.Verbosity == NuGet.Verbosity.Detailed)
                            {
                                Console.WriteWarning(e.ToString());
                            }
                            else
                            {
                                Console.WriteWarning(e.Message);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 31
0
 public RepositoryInfo(string path, string configFolderPath, IFileSystem fileSystem, ISharedPackageRepository repository)
 {
     Path = path;
     FileSystem = fileSystem;
     Repository = repository;
     ConfigFolderPath = configFolderPath;
 }
Exemplo n.º 32
0
        internal void UpdatePackages(IPackageRepository localRepository,
                                     IFileSystem sharedRepositoryFileSystem,
                                     ISharedPackageRepository sharedPackageRepository,
                                     IPackageRepository sourceRepository,
                                     IPackageConstraintProvider constraintProvider,
                                     IPackagePathResolver pathResolver,
                                     IProjectSystem project)
        {
            var packageManager = new PackageManager(sourceRepository, pathResolver, sharedRepositoryFileSystem, sharedPackageRepository);

            var projectManager = new ProjectManager(sourceRepository, pathResolver, project, localRepository)
                                 {
                                     ConstraintProvider = constraintProvider
                                 };

            // Fix for work item 2411: When updating packages, we did not add packages to the shared package repository. 
            // Consequently, when querying the package reference repository, we would have package references with no backing package files in
            // the shared repository. This would cause the reference repository to skip the package assuming that the entry is invalid.
            projectManager.PackageReferenceAdded += (sender, eventArgs) =>
            {
                PackageExtractor.InstallPackage(packageManager, eventArgs.Package);
            };

            projectManager.Logger = project.Logger = this;

            using (sourceRepository.StartOperation(RepositoryOperationNames.Update))
            {
                foreach (var package in GetPackages(localRepository))
                {
                    if (localRepository.Exists(package.Id))
                    {
                        try
                        {
                            // If the user explicitly allows prerelease or if the package being updated is prerelease we'll include prerelease versions in our list of packages
                            // being considered for an update.
                            bool allowPrerelease = Prerelease || !package.IsReleaseVersion();
                            if (Safe)
                            {
                                IVersionSpec safeRange = VersionUtility.GetSafeRange(package.Version);
                                projectManager.UpdatePackageReference(package.Id, safeRange, updateDependencies: true, allowPrereleaseVersions: allowPrerelease);
                            }
                            else
                            {
                                projectManager.UpdatePackageReference(package.Id, version: null, updateDependencies: true, allowPrereleaseVersions: allowPrerelease);
                            }
                        }
                        catch (InvalidOperationException e)
                        {
                            Console.WriteWarning(e.Message);
                        }
                    }
                }
            }
        }
		void CreateRepository(ConfigSettingsFileSystem configSettingsFileSystem)
		{
			repository = repositoryFactory.CreateSharedRepository(packagePathResolver, fileSystem, configSettingsFileSystem);			
		}
Exemplo n.º 34
0
        internal void UpdatePackages(IPackageRepository localRepository,
                                     IFileSystem sharedRepositoryFileSystem,
                                     ISharedPackageRepository sharedPackageRepository,
                                     IPackageRepository sourceRepository,
                                     IPackageConstraintProvider constraintProvider,
                                     IPackagePathResolver pathResolver,
                                     IProjectSystem project)
        {
            var packageManager = new PackageManager(sourceRepository, pathResolver, sharedRepositoryFileSystem, sharedPackageRepository);

            var projectManager = new ProjectManager(packageManager, pathResolver, project, localRepository)
                                 {
                                     ConstraintProvider = constraintProvider
                                 };

            // Fix for work item 2411: When updating packages, we did not add packages to the shared package repository. 
            // Consequently, when querying the package reference repository, we would have package references with no backing package files in
            // the shared repository. This would cause the reference repository to skip the package assuming that the entry is invalid.
            projectManager.PackageReferenceAdded += (sender, eventArgs) =>
            {
                PackageExtractor.InstallPackage(packageManager, eventArgs.Package);
            };

            projectManager.Logger = project.Logger = this;

            foreach (var package in GetPackages(localRepository))
            {
                if (localRepository.Exists(package.Id))
                {
                    using (sourceRepository.StartOperation(RepositoryOperationNames.Update, package.Id, mainPackageVersion: null))
                    {
                        try
                        {
                            // If the user explicitly allows prerelease or if the package being updated is prerelease we'll include prerelease versions in our list of packages
                            // being considered for an update.
                            bool allowPrerelease = Prerelease || !package.IsReleaseVersion();
                            var resolver = new ActionResolver()
                            {
                                AllowPrereleaseVersions = allowPrerelease
                            };
                            var updateUtility = new UpdateUtility(resolver)
                            {
                                AllowPrereleaseVersions = allowPrerelease,
                                Safe = Safe
                            };

                            var operations = updateUtility.ResolveActionsForUpdate(package.Id, null, new[] { projectManager }, false);
                            var userOperationExecutor = new ActionExecutor();
                            userOperationExecutor.Execute(operations);
                        }
                        catch (InvalidOperationException e)
                        {
                            if (Console.Verbosity == NuGet.Verbosity.Detailed)
                            {
                                Console.WriteWarning(e.ToString());
                            }
                            else
                            {
                                Console.WriteWarning(e.Message);
                            }
                        }
                    }
                }
            }
        }
 public MockVsPackageManager(
     ISolutionManager solutionManager,
     IPackageRepository sourceRepository,
     ISharedPackageRepository localRepository)
     : base(solutionManager, sourceRepository, new Mock<IFileSystemProvider>().Object, new MockFileSystem("x:\\root"), localRepository, new Mock<IDeleteOnRestartManager>().Object, new Mock<VsPackageInstallerEvents>().Object)
 {
 }
Exemplo n.º 36
0
 public RepositoryInfo(string path, IFileSystem fileSystem, ISharedPackageRepository repository)
 {
     Path       = path;
     FileSystem = fileSystem;
     Repository = repository;
 }
Exemplo n.º 37
0
        private void NugetifyProject(IVsProject projectAdapter, DirectoryInfo solutionRoot, ISharedPackageRepository existingSolutionPackagesRepo)
        {
            var projectNugetifier = CreateProjectNugetifier(projectAdapter);
            var packagesAdded = projectNugetifier.NugetifyReferences(solutionRoot);
            projectNugetifier.AddNugetReferenceMetadata(existingSolutionPackagesRepo, packagesAdded);
            projectAdapter.Save();

            if (NuSpec)
            {
                var manifestDependencies = projectNugetifier.GetManifestDependencies(packagesAdded);
                var nuspecBuilder = new NuspecBuilder(projectAdapter.AssemblyName);
                nuspecBuilder.SetMetadata(this, manifestDependencies);
                nuspecBuilder.SetDependencies(manifestDependencies);
                nuspecBuilder.Save(Console);
            }
        }
Exemplo n.º 38
0
 public RepositoryInfo(string path, IFileSystem fileSystem, ISharedPackageRepository repository)
 {
     Path = path;
     FileSystem = fileSystem;
     Repository = repository;
 }
 void CreateRepository(ConfigSettingsFileSystem configSettingsFileSystem)
 {
     repository = repositoryFactory.CreateSharedRepository(packagePathResolver, fileSystem, configSettingsFileSystem);
 }
		void CreateRepository()
		{
			repository = repositoryFactory.CreateSharedRepository(packagePathResolver, fileSystem);			
		}
        internal IEnumerable<PackageDependency> GetReferences(IPackageRepository localRepository,
                                     IFileSystem sharedRepositoryFileSystem,
                                     ISharedPackageRepository sharedPackageRepository,
                                     IPackageRepository sourceRepository,
                                     IPackageConstraintProvider constraintProvider,
                                     IPackagePathResolver pathResolver,
                                     IProjectSystem project)
        {
            var packageManager = new PackageManager(sourceRepository, pathResolver, sharedRepositoryFileSystem, sharedPackageRepository);

            var projectManager = new ProjectManager(sourceRepository, pathResolver, project, localRepository)
            {
                ConstraintProvider = constraintProvider
            };

            // Fix for work item 2411: When updating packages, we did not add packages to the shared package repository. 
            // Consequently, when querying the package reference repository, we would have package references with no backing package files in
            // the shared repository. This would cause the reference repository to skip the package assuming that the entry is invalid.
            projectManager.PackageReferenceAdded += (sender, eventArgs) =>
            {
                PackageExtractor.InstallPackage(packageManager, eventArgs.Package);
            };

            projectManager.Logger = project.Logger = new NugetUpdateTask.VerboseLogger(this);

            using (sourceRepository.StartOperation(RepositoryOperationNames.Update))
            {
                foreach (var package in GetPackages(localRepository))
                {
                    if (localRepository.Exists(package.Id))
                    {
                        if (projectManager.IsInstalled(package))
                        {
                            Log(Level.Debug, "Found installed package {0} version {1}", package.Id, package.Version);
                            yield return new PackageDependency(package.Id, new VersionSpec(package.Version));
                        }
                    }
                }
            }
        }
Exemplo n.º 42
0
        private void NugetifyProject(IVsProject projectAdapter, DirectoryInfo solutionRoot, ISharedPackageRepository existingSolutionPackagesRepo)
        {
            var targetFramework = TargetFramework != null?VersionUtility.ParseFrameworkName(TargetFramework) : null;

            var projectNugetifier = CreateProjectNugetifier(projectAdapter);
            var packagesAdded     = projectNugetifier.NugetifyReferences(solutionRoot);

            projectNugetifier.AddNugetReferenceMetadata(existingSolutionPackagesRepo, packagesAdded, targetFramework);
            projectAdapter.Save();

            if (NuSpec)
            {
                var manifestDependencies = projectNugetifier.GetManifestDependencies(packagesAdded);
                var nuspecBuilder        = new NuspecBuilder(projectAdapter.AssemblyName);
                nuspecBuilder.SetMetadata(this, manifestDependencies);
                nuspecBuilder.SetDependencies(manifestDependencies, TargetFramework);
                nuspecBuilder.Save(Console);
            }
        }
 private void RegisterPackagesConfig(ISharedPackageRepository sharedPackagesRepository)
 {
     var packagesConfigFilePath = Path.Combine(_vsProject.ProjectDirectory.FullName + "\\", PackageReferenceFilename);
     sharedPackagesRepository.RegisterRepository(packagesConfigFilePath);
     _vsProject.AddFile(PackageReferenceFilename);
 }
 public MockVsPackageManager(
     ISolutionManager solutionManager,
     IPackageRepository sourceRepository,
     IFileSystemProvider fileSystemProvider,
     IFileSystem fileSystem,
     ISharedPackageRepository sharedRepository,
     IDeleteOnRestartManager deleteOnRestartManager,
     VsPackageInstallerEvents packageEvents) :
     base(
         solutionManager,
         sourceRepository,
         fileSystemProvider,
         fileSystem,
         sharedRepository,
         deleteOnRestartManager,
         packageEvents)
 {
 }
 public NuGetAwareProjectPackageRepository(INuGetPackageManager project, ISharedPackageRepository sourceRepository)
 {
     _project = project;
     _repo = sourceRepository;
 }
 public NuGetAwareProjectPackageRepository(INuGetPackageManager project, ISharedPackageRepository sourceRepository)
 {
     _project = project;
     _repo    = sourceRepository;
 }
Exemplo n.º 47
0
 public PackageManager(IPackageRepository sourceRepository, IPackagePathResolver pathResolver, IFileSystem fileSystem, ISharedPackageRepository localRepository)
 {
     this._bindingRedirectEnabled = true;
     if (sourceRepository == null)
     {
         throw new ArgumentNullException("sourceRepository");
     }
     if (pathResolver == null)
     {
         throw new ArgumentNullException("pathResolver");
     }
     if (fileSystem == null)
     {
         throw new ArgumentNullException("fileSystem");
     }
     if (localRepository == null)
     {
         throw new ArgumentNullException("localRepository");
     }
     this.SourceRepository   = sourceRepository;
     this.DependencyResolver = new DependencyResolverFromRepo(sourceRepository);
     this.PathResolver       = pathResolver;
     this.FileSystem         = fileSystem;
     this.LocalRepository    = localRepository;
     this.DependencyVersion  = NuGet.DependencyVersion.Lowest;
     this.CheckDowngrade     = true;
 }