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


C# ProjectManager.UpdatePackageReference方法代码示例

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


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

示例1: UpdatePackageReferenceWithSatisfiableDependencies

        public void UpdatePackageReferenceWithSatisfiableDependencies()
        {
            // Arrange
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var projectManager = new ProjectManager(sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, new MockPackageRepository());

            // A 1.0 -> [B 1.0, C 1.0]
            IPackage packageA10 = PackageUtility.CreatePackage("A", "1.0",
                                                                dependencies: new List<PackageDependency> { 
                                                                        PackageDependency.CreateDependency("B", "[1.0]"),
                                                                        PackageDependency.CreateDependency("C", "[1.0]")
                                                                    }, content: new[] { "file" });

            IPackage packageB10 = PackageUtility.CreatePackage("B", "1.0", new[] { "Bfile" });
            IPackage packageC10 = PackageUtility.CreatePackage("C", "1.0", new[] { "Cfile" });

            // G 1.0 -> [C (>= 1.0)]
            IPackage packageG10 = PackageUtility.CreatePackage("G", "1.0",
                                                                dependencies: new List<PackageDependency> { 
                                                                        PackageDependency.CreateDependency("C", "1.0")
                                                                    }, content: new[] { "Gfile" });

            projectManager.LocalRepository.AddPackage(packageA10);
            projectManager.LocalRepository.AddPackage(packageB10);
            projectManager.LocalRepository.AddPackage(packageC10);
            projectManager.LocalRepository.AddPackage(packageG10);
            sourceRepository.AddPackage(packageA10);
            sourceRepository.AddPackage(packageB10);
            sourceRepository.AddPackage(packageC10);
            sourceRepository.AddPackage(packageG10);

            IPackage packageA20 = PackageUtility.CreatePackage("A", "2.0",
                                                                dependencies: new List<PackageDependency> { 
                                                                        PackageDependency.CreateDependency("B", "[1.0]"),
                                                                        PackageDependency.CreateDependency("C", "[2.0]"),
                                                                        PackageDependency.CreateDependency("D", "[1.0]")
                                                                    }, content: new[] { "A20file" });

            IPackage packageC20 = PackageUtility.CreatePackage("C", "2.0", new[] { "C20file" });
            IPackage packageD10 = PackageUtility.CreatePackage("D", "1.0", new[] { "D20file" });

            // A 2.0 -> [B 1.0, C 2.0, D 1.0]
            sourceRepository.AddPackage(packageA10);
            sourceRepository.AddPackage(packageA20);
            sourceRepository.AddPackage(packageB10);
            sourceRepository.AddPackage(packageC10);
            sourceRepository.AddPackage(packageC20);
            sourceRepository.AddPackage(packageD10);

            // Act
            projectManager.UpdatePackageReference("A");

            // Assert
            Assert.True(projectManager.LocalRepository.Exists(packageA20));
            Assert.True(projectManager.LocalRepository.Exists(packageB10));
            Assert.True(projectManager.LocalRepository.Exists(packageC20));
            Assert.True(projectManager.LocalRepository.Exists(packageD10));
            Assert.True(projectManager.LocalRepository.Exists(packageG10));

            Assert.False(projectManager.LocalRepository.Exists(packageC10));
            Assert.False(projectManager.LocalRepository.Exists(packageA10));
        }
开发者ID:riteshparekh,项目名称:NuGet,代码行数:63,代码来源:ProjectManagerTest.cs

示例2: UpdatePackageReferenceUpdateToNewerVersionIfPrereleaseFlagIsSet

        public void UpdatePackageReferenceUpdateToNewerVersionIfPrereleaseFlagIsSet()
        {
            // Arrange
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var projectManager = new ProjectManager(sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, new MockPackageRepository());

            var packageA1 = PackageUtility.CreatePackage("A", "1.0", content: new string[] {"good"});
            var packageA2 = PackageUtility.CreatePackage("A", "2.0-alpha", content: new string[] {"excellent"});

            // project has A 1.0 installed
            projectManager.LocalRepository.AddPackage(packageA1);

            sourceRepository.AddPackage(packageA2);

            // Act
            projectManager.UpdatePackageReference("A", version: null, updateDependencies: false, allowPrereleaseVersions: true);

            // Assert
            Assert.True(projectManager.LocalRepository.Exists("A", new SemanticVersion("2.0-alpha")));
        }
开发者ID:riteshparekh,项目名称:NuGet,代码行数:21,代码来源:ProjectManagerTest.cs

示例3: UpdatePackageReferenceThrowsIfTheNewPackageHasDependencyMinClientVersionNotSatisfied

        public void UpdatePackageReferenceThrowsIfTheNewPackageHasDependencyMinClientVersionNotSatisfied()
        {
            // Arrange
            Version nugetVersion = typeof(IPackage).Assembly.GetName().Version;
            Version requiredVersion = new Version(nugetVersion.Major, nugetVersion.Minor, nugetVersion.Build, nugetVersion.Revision + 1);

            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var projectManager = new ProjectManager(sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, new MockPackageRepository());

            var packageA1 = PackageUtility.CreatePackage("A", "1.0", content: new string[] { "good" });
            var packageA2 = PackageUtility.CreatePackage(
                "A", 
                "2.0-alpha", 
                content: new string[] { "excellent" }, 
                dependencies: new PackageDependency[] { new PackageDependency("B") });

            IPackage packageB = PackageUtility.CreatePackage("B", "2.0", assemblyReferences: new[] { "lib\\you.dll" }, minClientVersion: requiredVersion.ToString());

            // project has A 1.0 installed
            projectManager.LocalRepository.AddPackage(packageA1);

            sourceRepository.AddPackage(packageA2);
            sourceRepository.AddPackage(packageB);

            string expectedErrorMessage =
                String.Format("The '{0}' package requires NuGet client version '{1}' or above, but the current NuGet version is '{2}'.", "B 2.0", requiredVersion.ToString(), nugetVersion.ToString());

            // Act && Assert
            ExceptionAssert.Throws<NuGetVersionNotSatisfiedException>(
                () => projectManager.UpdatePackageReference("A", version: null, updateDependencies: true, allowPrereleaseVersions: true),
                expectedErrorMessage);
        }
开发者ID:riteshparekh,项目名称:NuGet,代码行数:33,代码来源:ProjectManagerTest.cs

示例4: UpdatePackageReferenceShouldLeaveDependencyPackageAloneIfItSatisfiesTheVersionConstraint2

        public void UpdatePackageReferenceShouldLeaveDependencyPackageAloneIfItSatisfiesTheVersionConstraint2()
        {
            // Arrange            
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var projectManager = new ProjectManager(sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, new MockPackageRepository());
            IPackage packageA1 = PackageUtility.CreatePackage(
                "A",
                "1.0.0",
                dependencies: new[] { new PackageDependency("B", VersionUtility.ParseVersionSpec("1.0.0")) },
                assemblyReferences: new[] { "lib\\a1.dll" });

            IPackage packageA2 = PackageUtility.CreatePackage(
                "A",
                "2.0.0",
                dependencies: new[] { new PackageDependency("B", VersionUtility.ParseVersionSpec("1.0.0")) },
                assemblyReferences: new[] { "lib\\a2.dll" });

            IPackage packageB1 = PackageUtility.CreatePackage(
               "B",
               "1.0.0",
               assemblyReferences: new[] { "lib\\b1.dll" });

            IPackage packageB2 = PackageUtility.CreatePackage(
               "B",
               "1.0.2",
               assemblyReferences: new[] { "lib\\b2.dll" });

            sourceRepository.AddPackage(packageA1);
            sourceRepository.AddPackage(packageA2);
            sourceRepository.AddPackage(packageB1);
            sourceRepository.AddPackage(packageB2);

            projectManager.LocalRepository.AddPackage(packageA1);
            projectManager.LocalRepository.AddPackage(packageB1);

            // Act
            // Now install B, which depends on A >= 1.1.0.
            projectManager.UpdatePackageReference("A");

            // Assert
            // NuGet should leave version 1.1.2 intact, because it already satisfies the version spec
            // It should not upgrade A to 1.1.9
            Assert.True(projectManager.LocalRepository.Exists("A", new SemanticVersion("2.0.0")));
            Assert.True(projectManager.LocalRepository.Exists("B", new SemanticVersion("1.0")));
            Assert.False(projectManager.LocalRepository.Exists("B", new SemanticVersion("1.0.2")));
        }
开发者ID:riteshparekh,项目名称:NuGet,代码行数:47,代码来源:ProjectManagerTest.cs

示例5: UpdatePackageReferenceFromRepositoryThrowsIfPackageHasDependents

        public void UpdatePackageReferenceFromRepositoryThrowsIfPackageHasDependents()
        {
            // Arrange
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var projectManager = new ProjectManager(sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, new MockPackageRepository());
            IPackage packageA10 = PackageUtility.CreatePackage("A", "1.0",
                                                                dependencies: new List<PackageDependency> {
                                                                        PackageDependency.CreateDependency("B", "[1.0]")
                                                                    }, content: new[] { "afile" });
            IPackage packageB10 = PackageUtility.CreatePackage("B", "1.0", content: new[] { "bfile" });
            IPackage packageB20 = PackageUtility.CreatePackage("B", "2.0", content: new[] { "cfile" });
            projectManager.LocalRepository.AddPackage(packageA10);
            projectManager.LocalRepository.AddPackage(packageB10);
            sourceRepository.AddPackage(packageA10);
            sourceRepository.AddPackage(packageB10);
            sourceRepository.AddPackage(packageB20);

            // Act & Assert
            ExceptionAssert.Throws<InvalidOperationException>(() => projectManager.UpdatePackageReference("B"), "Conflict occurred. 'B 1.0' referenced but requested 'B 2.0'. 'A 1.0' depends on 'B 1.0'.");
        }
开发者ID:larsw,项目名称:nuget,代码行数:21,代码来源:ProjectManagerTest.cs

示例6: UpdatePackageReferenceFromRepositoryOverlappingDependencies

        public void UpdatePackageReferenceFromRepositoryOverlappingDependencies()
        {
            // Arrange
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var projectManager = new ProjectManager(sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, new MockPackageRepository());
            // A 1.0 -> B 1.0
            IPackage packageA10 = PackageUtility.CreatePackage("A", "1.0",
                                                                dependencies: new List<PackageDependency> { 
                                                                        PackageDependency.CreateDependency("B", "[1.0]")
                                                                    }, content: new[] { "afile" });

            // A 2.0 -> B [2.0]
            IPackage packageA20 = PackageUtility.CreatePackage("A", "2.0",
                                                                dependencies: new List<PackageDependency> { 
                                                                        PackageDependency.CreateDependency("B", "[2.0]")
                                                                    }, content: new[] { "afile" });

            // B 1.0
            IPackage packageB10 = PackageUtility.CreatePackage("B", "1.0", content: new[] { "b1file" });

            // B 2.0 -> C 2.0
            IPackage packageB20 = PackageUtility.CreatePackage("B", "2.0",
                                                                dependencies: new List<PackageDependency> { 
                                                                        PackageDependency.CreateDependency("C", "2.0")
                                                                    }, content: new[] { "afile" });

            // C 2.0
            IPackage packageC20 = PackageUtility.CreatePackage("C", "2.0", content: new[] { "c2file" });

            projectManager.LocalRepository.AddPackage(packageA10);
            projectManager.LocalRepository.AddPackage(packageB10);
            sourceRepository.AddPackage(packageA10);
            sourceRepository.AddPackage(packageA20);
            sourceRepository.AddPackage(packageB10);
            sourceRepository.AddPackage(packageB20);
            sourceRepository.AddPackage(packageC20);

            // Act
            projectManager.UpdatePackageReference("B");

            // Assert
            Assert.False(projectManager.LocalRepository.Exists(packageA10));
            Assert.False(projectManager.LocalRepository.Exists(packageB10));
            Assert.True(projectManager.LocalRepository.Exists(packageA20));
            Assert.True(projectManager.LocalRepository.Exists(packageB20));
            Assert.True(projectManager.LocalRepository.Exists(packageC20));
        }
开发者ID:riteshparekh,项目名称:NuGet,代码行数:48,代码来源:ProjectManagerTest.cs

示例7: UpdatePackageReferenceNoVersionSpecifiedShouldUpdateToLatest

        public void UpdatePackageReferenceNoVersionSpecifiedShouldUpdateToLatest()
        {
            // Arrange
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var projectManager = new ProjectManager(sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, new MockPackageRepository());
            IPackage package10 = PackageUtility.CreatePackage("NetFramework", "1.0", content: new[] { "1.0f" });
            projectManager.LocalRepository.AddPackage(package10);
            sourceRepository.AddPackage(package10);

            IPackage package11 = PackageUtility.CreatePackage("NetFramework", "1.1", content: new[] { "1.1f" });
            sourceRepository.AddPackage(package11);

            IPackage package20 = PackageUtility.CreatePackage("NetFramework", "2.0", content: new[] { "2.0f" });
            sourceRepository.AddPackage(package20);

            IPackage package35 = PackageUtility.CreatePackage("NetFramework", "3.5", content: new[] { "3.5f" });
            sourceRepository.AddPackage(package35);

            // Act
            projectManager.UpdatePackageReference("NetFramework");

            // Assert
            Assert.False(projectManager.LocalRepository.Exists(package10));
            Assert.True(projectManager.LocalRepository.Exists(package35));
        }
开发者ID:riteshparekh,项目名称:NuGet,代码行数:26,代码来源:ProjectManagerTest.cs

示例8: UpdatePackageReferenceIfPackageNotReferencedThrows

        public void UpdatePackageReferenceIfPackageNotReferencedThrows()
        {
            // Arrange
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var projectManager = new ProjectManager(sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, new MockPackageRepository());

            // Act & Assert
            ExceptionAssert.Throws<InvalidOperationException>(() => projectManager.UpdatePackageReference("A"), @"x:\MockFileSystem does not reference 'A'.");
        }
开发者ID:riteshparekh,项目名称:NuGet,代码行数:10,代码来源:ProjectManagerTest.cs

示例9: UpdatePackageReferenceToOlderVersionDowngradesPackage

        public void UpdatePackageReferenceToOlderVersionDowngradesPackage()
        {
            // Arrange
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var projectManager = new ProjectManager(sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, new MockPackageRepository());

            // A 1.0 -> [B 1.0]
            IPackage packageA10 = PackageUtility.CreatePackage("A", "1.0");
            IPackage packageA20 = PackageUtility.CreatePackage("A", "2.0");
            IPackage packageA30 = PackageUtility.CreatePackage("A", "3.0");

            sourceRepository.AddPackage(packageA10);
            sourceRepository.AddPackage(packageA20);
            sourceRepository.AddPackage(packageA30);

            projectManager.LocalRepository.AddPackage(packageA20);

            // Act & Assert
            projectManager.UpdatePackageReference("A", new SemanticVersion("2.0"));
            Assert.False(projectManager.LocalRepository.Exists(packageA30));
            Assert.True(projectManager.LocalRepository.Exists(packageA20));
        }
开发者ID:riteshparekh,项目名称:NuGet,代码行数:23,代码来源:ProjectManagerTest.cs

示例10: UpdatePackageReferenceToOlderVersionThrows

        public void UpdatePackageReferenceToOlderVersionThrows()
        {
            // Arrange
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var projectManager = new ProjectManager(sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, new MockPackageRepository());

            // A 1.0 -> [B 1.0]
            IPackage packageA10 = PackageUtility.CreatePackage("A", "1.0");
            IPackage packageA20 = PackageUtility.CreatePackage("A", "2.0");
            IPackage packageA30 = PackageUtility.CreatePackage("A", "3.0");

            sourceRepository.AddPackage(packageA10);
            sourceRepository.AddPackage(packageA20);
            sourceRepository.AddPackage(packageA30);

            projectManager.LocalRepository.AddPackage(packageA20);

            // Act & Assert
            ExceptionAssert.Throws<InvalidOperationException>(() => projectManager.UpdatePackageReference("A", version: SemanticVersion.Parse("1.0")), @"Already referencing a newer version of 'A'.");
        }
开发者ID:ebenoit,项目名称:NuGet,代码行数:21,代码来源:ProjectManagerTest.cs

示例11: UpdatePackageReferenceWithMixedDependenciesUpdatesPackageAndDependenciesIfUnused

        public void UpdatePackageReferenceWithMixedDependenciesUpdatesPackageAndDependenciesIfUnused()
        {
            // Arrange
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var projectManager = new ProjectManager(sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, new MockPackageRepository());

            // A 1.0 -> [B 1.0, C 1.0]
            IPackage packageA10 = PackageUtility.CreatePackage("A",
                                                               "1.0",
                                                               dependencies: new List<PackageDependency> { 
                                                                    PackageDependency.CreateDependency("B","[1.0]"),
                                                                    PackageDependency.CreateDependency("C","[1.0]")
                                                                }, content: new[] { "A.file" });

            IPackage packageB10 = PackageUtility.CreatePackage("B", "1.0", content: new[] { "B.fie" });
            IPackage packageC10 = PackageUtility.CreatePackage("C", "1.0", content: new[] { "C.file" });

            sourceRepository.AddPackage(packageA10);
            sourceRepository.AddPackage(packageB10);
            sourceRepository.AddPackage(packageC10);
            projectManager.LocalRepository.AddPackage(packageA10);
            projectManager.LocalRepository.AddPackage(packageB10);
            projectManager.LocalRepository.AddPackage(packageC10);

            IPackage packageA20 = PackageUtility.CreatePackage("A", "2.0",
                                                               dependencies: new List<PackageDependency> { 
                                                                                    PackageDependency.CreateDependency("B", "[1.0]"),
                                                                                    PackageDependency.CreateDependency("C", "[2.0]"),
                                                                                    PackageDependency.CreateDependency("D", "[1.0]")
                                                               }, content: new[] { "A.20.file" });

            IPackage packageC20 = PackageUtility.CreatePackage("C", "2.0", content: new[] { "C.20" });
            IPackage packageD10 = PackageUtility.CreatePackage("D", "1.0", content: new[] { "D.20" });

            // A 2.0 -> [B 1.0, C 2.0, D 1.0]
            sourceRepository.AddPackage(packageA10);
            sourceRepository.AddPackage(packageA20);
            sourceRepository.AddPackage(packageB10);
            sourceRepository.AddPackage(packageC10);
            sourceRepository.AddPackage(packageC20);
            sourceRepository.AddPackage(packageD10);

            // Act
            projectManager.UpdatePackageReference("A");

            // Assert
            Assert.True(projectManager.LocalRepository.Exists(packageA20));
            Assert.True(projectManager.LocalRepository.Exists(packageB10));
            Assert.True(projectManager.LocalRepository.Exists(packageC20));
            Assert.True(projectManager.LocalRepository.Exists(packageD10));
            Assert.False(projectManager.LocalRepository.Exists(packageA10));
            Assert.False(projectManager.LocalRepository.Exists(packageC10));
        }
开发者ID:riteshparekh,项目名称:NuGet,代码行数:54,代码来源:ProjectManagerTest.cs

示例12: UpdatePackages

        internal void UpdatePackages(IPackageRepository localRepository,
                                     IPackageRepository sourceRepository,
                                     IPackageConstraintProvider constraintProvider,
                                     IPackagePathResolver pathResolver,
                                     IProjectSystem project)
        {
            var projectManager = new ProjectManager(sourceRepository, pathResolver, project, localRepository)
                                 {
                                     ConstraintProvider = constraintProvider
                                 };

            if (Verbose)
            {
                projectManager.Logger = Console;
            }

            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);
                    }
                }
            }
        }
开发者ID:xero-github,项目名称:Nuget,代码行数:42,代码来源:UpdateCommand.cs

示例13: UpdateDependencyDependentsHaveSatisfyableDependencies

        public void UpdateDependencyDependentsHaveSatisfyableDependencies()
        {
            // Arrange
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var projectManager = new ProjectManager(sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, new MockPackageRepository());

            // A 1.0 -> [C >= 1.0]
            IPackage packageA10 = PackageUtility.CreatePackage("A", "1.0",
                                                                dependencies: new List<PackageDependency> {                                                                         
                                                                        PackageDependency.CreateDependency("C", "1.0")
                                                                    }, content: new[] { "A" });

            // B 1.0 -> [C <= 2.0]
            IPackage packageB10 = PackageUtility.CreatePackage("B", "1.0",
                                                                dependencies: new List<PackageDependency> {                                                                         
                                                                        PackageDependency.CreateDependency("C", "2.0")
                                                                    }, content: new[] { "B" });

            IPackage packageC10 = PackageUtility.CreatePackage("C", "1.0", content: new[] { "C" });

            projectManager.LocalRepository.AddPackage(packageA10);
            projectManager.LocalRepository.AddPackage(packageB10);
            projectManager.LocalRepository.AddPackage(packageC10);
            sourceRepository.AddPackage(packageA10);
            sourceRepository.AddPackage(packageB10);
            sourceRepository.AddPackage(packageC10);

            IPackage packageC20 = PackageUtility.CreatePackage("C", "2.0", content: new[] { "C2" });

            // A 2.0 -> [B 1.0, C 2.0, D 1.0]
            sourceRepository.AddPackage(packageA10);
            sourceRepository.AddPackage(packageB10);
            sourceRepository.AddPackage(packageC10);
            sourceRepository.AddPackage(packageC20);

            // Act
            projectManager.UpdatePackageReference("C");

            // Assert
            Assert.True(projectManager.LocalRepository.Exists(packageA10));
            Assert.True(projectManager.LocalRepository.Exists(packageB10));
            Assert.True(projectManager.LocalRepository.Exists(packageC20));
            Assert.False(projectManager.LocalRepository.Exists(packageC10));
        }
开发者ID:monoman,项目名称:NugetCracker,代码行数:45,代码来源:ProjectManagerTest.cs

示例14: 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 = 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);
                        }
                    }
                }
            }
        }
开发者ID:shrknt35,项目名称:sonarlint-vs,代码行数:54,代码来源:UpdateCommand.cs

示例15: UpdatePackageReferenceWithDependenciesInUseThrowsConflictError

        public void UpdatePackageReferenceWithDependenciesInUseThrowsConflictError()
        {
            // Arrange
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var projectManager = new ProjectManager(sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, new MockPackageRepository());

            // A 1.0 -> [B 1.0, C 1.0]
            IPackage packageA10 = PackageUtility.CreatePackage("A", "1.0",
                                                                dependencies: new List<PackageDependency> { 
                                                                        PackageDependency.CreateDependency("B", "[1.0]"),
                                                                        PackageDependency.CreateDependency("C", "[1.0]")
                                                                    }, content: new[] { "afile" });

            IPackage packageB10 = PackageUtility.CreatePackage("B", "1.0", content: new[] { "Bfile" });
            IPackage packageC10 = PackageUtility.CreatePackage("C", "1.0", content: new[] { "Cfile" });

            // G 1.0 -> [C 1.0]
            IPackage packageG10 = PackageUtility.CreatePackage("G", "1.0",
                                                                dependencies: new List<PackageDependency> { 
                                                                        PackageDependency.CreateDependency("C", "[1.0]")
                                                                    }, content: new[] { "gfile" });

            projectManager.LocalRepository.AddPackage(packageA10);
            projectManager.LocalRepository.AddPackage(packageB10);
            projectManager.LocalRepository.AddPackage(packageC10);
            projectManager.LocalRepository.AddPackage(packageG10);
            sourceRepository.AddPackage(packageA10);
            sourceRepository.AddPackage(packageB10);
            sourceRepository.AddPackage(packageC10);
            sourceRepository.AddPackage(packageG10);

            IPackage packageA20 = PackageUtility.CreatePackage("A", "2.0",
                                                                dependencies: new List<PackageDependency> { 
                                                                        PackageDependency.CreateDependency("B", "[1.0]"),
                                                                        PackageDependency.CreateDependency("C", "[2.0]"),
                                                                        PackageDependency.CreateDependency("D", "[1.0]")
                                                                    }, content: new[] { "a20file" });

            IPackage packageC20 = PackageUtility.CreatePackage("C", "2.0", content: new[] { "cfile" });
            IPackage packageD10 = PackageUtility.CreatePackage("D", "1.0", content: new[] { "dfile" });

            // A 2.0 -> [B 1.0, C 2.0, D 1.0]
            sourceRepository.AddPackage(packageA10);
            sourceRepository.AddPackage(packageA20);
            sourceRepository.AddPackage(packageB10);
            sourceRepository.AddPackage(packageC10);
            sourceRepository.AddPackage(packageC20);
            sourceRepository.AddPackage(packageD10);

            // Act 
            ExceptionAssert.Throws<InvalidOperationException>(() => projectManager.UpdatePackageReference("A"), "Updating 'C 1.0' to 'C 2.0' failed. Unable to find a version of 'G' that is compatible with 'C 2.0'.");
        }
开发者ID:riteshparekh,项目名称:NuGet,代码行数:53,代码来源:ProjectManagerTest.cs


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