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


C# PackageManager.UninstallPackage方法代码示例

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


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

示例1: UninstallingPackageWithNoDependents

        public void UninstallingPackageWithNoDependents()
        {
            // Arrange
            var localRepository = new MockPackageRepository();
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var packageManager = new PackageManager(sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, localRepository);
            var package = PackageUtility.CreatePackage("foo", "1.2.33");
            localRepository.AddPackage(package);

            // Act
            packageManager.UninstallPackage("foo");

            // Assert
            Assert.False(packageManager.LocalRepository.Exists(package));
        }
开发者ID:atheken,项目名称:nuget,代码行数:16,代码来源:PackageManagerTest.cs

示例2: InstallPackage

        /// <summary>
        /// Installs the package.
        /// </summary>
        /// <param name="packageManager">The package manager.</param>
        /// <param name="fileSystem">The file system.</param>
        /// <param name="packageId">The package id.</param>
        /// <param name="version">The version.</param>
        /// <param name="allowPreReleaseVersion"> </param>
        /// <returns></returns>
        internal bool InstallPackage(PackageManager packageManager, IFileSystem fileSystem, string packageId, SemanticVersion version, Boolean allowPreReleaseVersion = true)
        {
            if (packageManager.IsPackageInstalled(packageId, version))
            {
                return false;
            }

            if (!AllowMultipleVersions)
            {
                var installedPackage = packageManager.LocalRepository.FindPackage(packageId);
                if (installedPackage != null)
                {
                    if (version != null && installedPackage.Version >= version)
                    {
                        // If the package is already installed (or the version being installed is lower), then we do not need to do anything. 
                        return false;
                    }
                    else if (packageManager.SourceRepository.Exists(packageId, version))
                    {
                        // If the package is already installed, but
                        // (a) the version we require is different from the one that is installed, 
                        // (b) side-by-side is disabled
                        // we need to uninstall it.
                        // However, before uninstalling, make sure the package exists in the source repository. 
                        packageManager.UninstallPackage(installedPackage, forceRemove: true, removeDependencies: false);
                    }
                }
            }
            //TODO Will need to expose the last boolean here......
            var package = _packageResolutionManager.ResolvePackage(packageManager.LocalRepository, _repository, packageId, version, allowPreReleaseVersion);
            packageManager.InstallPackage(package, ignoreDependencies: !IncludeDependencies, allowPrereleaseVersions: allowPreReleaseVersion);
            //packageManager.InstallPackage(packageId, version, !IncludeDependencies, allowPreReleaseVersion);
            return true;
        }
开发者ID:dipeshc,项目名称:NuGet.Extensions,代码行数:43,代码来源:Get.cs

示例3: UninstallingPackageUninstallsPackageButNotDependencies

        public void UninstallingPackageUninstallsPackageButNotDependencies()
        {
            // Arrange
            var localRepository = new MockPackageRepository();
            var sourceRepository = new MockPackageRepository();
            var projectSystem = new MockProjectSystem();
            var packageManager = new PackageManager(sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, localRepository);

            IPackage packageA = PackageUtility.CreatePackage("A", "1.0",
                                                            dependencies: new List<PackageDependency> {
                                                                new PackageDependency("B")
                                                            });

            IPackage packageB = PackageUtility.CreatePackage("B", "1.0");

            localRepository.AddPackage(packageA);
            localRepository.AddPackage(packageB);

            // Act
            packageManager.UninstallPackage("A");

            // Assert            
            Assert.False(localRepository.Exists(packageA));
            Assert.True(localRepository.Exists(packageB));
        }
开发者ID:atheken,项目名称:nuget,代码行数:25,代码来源:PackageManagerTest.cs

示例4: UninstallingSatellitePackageRemovesCollidingRuntimeFiles

        public void UninstallingSatellitePackageRemovesCollidingRuntimeFiles()
        {
            // Arrange
            // Create a runtime package and a satellite package that has a dependency on the runtime package, and uses the
            // local suffix convention.
            var runtimePackage = PackageUtility.CreatePackage("foo", "1.0.0",
                                                    assemblyReferences: new[] { @"lib\ja-jp\collision.txt" });

            var satellitePackage = PackageUtility.CreatePackage("foo.ja-jp", "1.0.0", language: "ja-jp",
                                                    satelliteAssemblies: new[] { @"lib\ja-jp\collision.txt" },
                                                    dependencies: new[] { new PackageDependency("foo", VersionUtility.ParseVersionSpec("[1.0.0]")) });

            var projectSystem = new MockProjectSystem();
            var localRepository = new MockPackageRepository();
            var sourceRepository = new MockPackageRepository();
            var packageManager = new PackageManager(sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, localRepository);
            sourceRepository.AddPackage(runtimePackage);
            sourceRepository.AddPackage(satellitePackage);

            // Act
            packageManager.InstallPackage("foo");
            packageManager.InstallPackage("foo.ja-jp");

            packageManager.UninstallPackage("foo.ja-jp");

            // Assert
            Assert.Equal(0, projectSystem.Paths.Count);
            Assert.False(projectSystem.FileExists(@"foo.1.0.0\lib\ja-jp\collision.txt"));
        }
开发者ID:atheken,项目名称:nuget,代码行数:29,代码来源:PackageManagerTest.cs

示例5: UninstallingSatellitePackageRemovesFilesFromRuntimePackageFolder

        public void UninstallingSatellitePackageRemovesFilesFromRuntimePackageFolder()
        {
            // Arrange
            // Create a runtime package and a satellite package that has a dependency on the runtime package, and uses the
            // local suffix convention.
            var runtimePackage = PackageUtility.CreatePackage("foo", "1.0.0",
                                                    assemblyReferences: new[] {
                                                        @"lib\foo.dll" },
                                                    content: new[] {
                                                        @"english.txt" });

            var satellitePackage = PackageUtility.CreatePackage("foo.ja-jp", "1.0.0", language: "ja-jp",
                                                    satelliteAssemblies: new[] {
                                                        @"lib\ja-jp\foo.resources.dll",
                                                        @"lib\ja-jp\foo.xml",
                                                        @"lib\japanese.xml" },
                                                    content: new[] {
                                                        @"english.txt",
                                                        @"japanese.txt" },
                                                    dependencies: new[] { new PackageDependency("foo") });

            var projectSystem = new MockProjectSystem();
            var localRepository = new MockPackageRepository();
            var sourceRepository = new MockPackageRepository();
            var packageManager = new PackageManager(sourceRepository, new DefaultPackagePathResolver(projectSystem), projectSystem, localRepository);
            sourceRepository.AddPackage(runtimePackage);
            sourceRepository.AddPackage(satellitePackage);

            // Act
            packageManager.InstallPackage("foo");
            packageManager.InstallPackage("foo.ja-jp");

            packageManager.UninstallPackage("foo.ja-jp");

            // Assert
            Assert.Equal(2, projectSystem.Paths.Count);
            Assert.True(projectSystem.FileExists(@"foo.1.0.0\content\english.txt"));
            Assert.True(projectSystem.FileExists(@"foo.1.0.0\lib\foo.dll"));
            Assert.False(projectSystem.FileExists(@"foo.1.0.0\lib\ja-jp\foo.resources.dll"));
            Assert.False(projectSystem.FileExists(@"foo.1.0.0\lib\ja-jp\foo.xml"));

            Assert.False(projectSystem.FileExists(@"foo.ja-jp.1.0.0\content\english.txt"));
            Assert.False (projectSystem.FileExists(@"foo.ja-jp.1.0.0\content\japanese.txt"));
            Assert.False(projectSystem.FileExists(@"foo.ja-jp.1.0.0\lib\japanese.xml"));
            Assert.False(projectSystem.FileExists(@"foo.ja-jp.1.0.0\lib\ja-jp\foo.resources.dll"));
            Assert.False(projectSystem.FileExists(@"foo.ja-jp.1.0.0\lib\ja-jp\foo.xml"));

            Assert.False(projectSystem.FileExists(@"foo.1.0.0\lib\japanese.xml"));
            Assert.False(projectSystem.FileExists(@"foo.1.0.0\content\japanese.txt"));
        }
开发者ID:atheken,项目名称:nuget,代码行数:50,代码来源:PackageManagerTest.cs

示例6: UninstallGalleryPackage

        private static void UninstallGalleryPackage(string pkgId)
        {
            // if installed from gallery, also remove NuGet package files
            var packageManager = new PackageManager(
                _repository,
                new DefaultPackagePathResolver(BlogConfig.GalleryFeedUrl),
                new PhysicalFileSystem(HttpContext.Current.Server.MapPath(Utils.ApplicationRelativeWebRoot + "App_Data/packages"))
            );
            var package = _repository.FindPackage(pkgId);

            if (package != null)
                packageManager.UninstallPackage(package, true);
        }
开发者ID:aelagawy,项目名称:BlogEngine.NET,代码行数:13,代码来源:Installer.cs

示例7: UninstallPackage

        /// <summary>
        /// Uninstall package
        /// </summary>
        /// <param name="pkgId"></param>
        /// <returns></returns>
        public static JsonResponse UninstallPackage(string pkgId)
        {
            try
            {
                var packageManager = new PackageManager(
                    _repository,
                    new DefaultPackagePathResolver(BlogSettings.Instance.GalleryFeedUrl),
                    new PhysicalFileSystem(HttpContext.Current.Server.MapPath(Utils.ApplicationRelativeWebRoot + "App_Data/packages"))
                );

                var package = _repository.FindPackage(pkgId);

                if (package == null)
                    return new JsonResponse { Success = false, Message = "Package " + pkgId + " not found" };

                packageManager.UninstallPackage(package, true);

                FileSystem.UninstallPackage(package.Id);

                BlogService.DeletePackage(pkgId);

                // reset cache
                Blog.CurrentInstance.Cache.Remove(Constants.CacheKey);

                Utils.Log(string.Format("Uninstalled package {0} by {1}", pkgId, Security.CurrentUser.Identity.Name));
            }
            catch (Exception ex)
            {
                Utils.Log("BlogEngine.Core.Packaging.Installer.UninstallPackage(" + pkgId + ")", ex);
                return new JsonResponse { Success = false, Message = "Error uninstalling package, see logs for details" };
            }

            return new JsonResponse { Success = true, Message = "Package successfully uninstalled" };
        }
开发者ID:sagasu,项目名称:tddLegacy,代码行数:39,代码来源:Installer.cs


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