当前位置: 首页>>代码示例>>C#>>正文


C# ProjectManager.IsInstalled方法代码示例

本文整理汇总了C#中ProjectManager.IsInstalled方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectManager.IsInstalled方法的具体用法?C# ProjectManager.IsInstalled怎么用?C# ProjectManager.IsInstalled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProjectManager的用法示例。


在下文中一共展示了ProjectManager.IsInstalled方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetReferences

        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));
                        }
                    }
                }
            }
        }
开发者ID:Alxandr,项目名称:NAnt.Nuget.Tasks,代码行数:40,代码来源:NugetGetDependenciesTask.cs

示例2: UpdatePackageWhenAnUnusedVersionOfPackageIsPresentInPackagesFolder

        public void UpdatePackageWhenAnUnusedVersionOfPackageIsPresentInPackagesFolder()
        {
            // Arrange
            var localRepository = new Mock<MockPackageRepository>() { CallBase = true }.As<ISharedPackageRepository>();
            localRepository.Setup(m => m.IsReferenced("A", new SemanticVersion("2.0"))).Returns(true);
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var pathResolver = new DefaultPackagePathResolver(projectSystem);
            var projectManager = new ProjectManager(sourceRepository, pathResolver, projectSystem, localRepository.Object);
            var project = TestUtils.GetProject("foo");
            var projects = new Project[] { project };

            var packageA10 = PackageUtility.CreatePackage("A", "1.0", new string[] { "hello.txt" });
            var packageA20 = PackageUtility.CreatePackage("A", "2.0", new string[] { "hello.txt" });
            var packageA30 = PackageUtility.CreatePackage("A", "3.0", new string[] { "hello.txt" });
            localRepository.Object.AddPackage(packageA10);
            sourceRepository.AddPackage(packageA10);
            sourceRepository.AddPackage(packageA20);
            sourceRepository.AddPackage(packageA30);

            var packageManager = new Mock<VsPackageManager>(
                TestUtils.GetSolutionManager(true, "foo", projects),
                sourceRepository,
                new Mock<IFileSystemProvider>().Object,
                projectSystem,
                localRepository.Object,
                new Mock<IDeleteOnRestartManager>().Object,
                new Mock<VsPackageInstallerEvents>().Object,
                /* multiFrameworkTargeting */ null) { CallBase = true };

            packageManager.Setup(p => p.GetProjectManager(It.IsAny<Project>())).Returns(projectManager);

            packageManager.Object.InstallPackage(projectManager, "A", packageA20.Version, true, true, null);

            // Act
            packageManager.Object.UpdatePackage("A", (IVersionSpec)null, true, true, null, null);

            // Assert
            Assert.True(localRepository.Object.Exists(packageA10));
            Assert.False(localRepository.Object.Exists(packageA20));
            Assert.True(localRepository.Object.Exists(packageA30));

            Assert.False(projectManager.IsInstalled(packageA20));
            Assert.True(projectManager.IsInstalled(packageA30));
        }
开发者ID:Berzeger,项目名称:NuGet,代码行数:45,代码来源:VsPackageManagerTest.cs

示例3: UpdatePackages

        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);
                        }
                    }
                }
            }
        }
开发者ID:Alxandr,项目名称:NAnt.Nuget.Tasks,代码行数:56,代码来源:NugetUpdateTask.cs


注:本文中的ProjectManager.IsInstalled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。