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


C# IPackage.HasPowerShellScript方法代码示例

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


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

示例1: ExecuteScript

 public static void ExecuteScript(this IScriptExecutor executor, string installPath, string scriptFileName, IPackage package, Project project, ILogger logger)
 {
     if (package.HasPowerShellScript(new[] { scriptFileName }))
     {
         executor.Execute(installPath, scriptFileName, package, project, logger);
     }
 }
开发者ID:xero-github,项目名称:Nuget,代码行数:7,代码来源:ScriptExecutorExtensions.cs

示例2: AskRemoveDependencyAndCheckUninstallPSScript

        protected bool? AskRemoveDependencyAndCheckUninstallPSScript(IPackage package, bool checkDependents)
        {
            if (checkDependents)
            {
                // check if there is any other package depends on this package.
                // if there is, throw to cancel the uninstallation
                var dependentsWalker = new DependentsWalker(LocalRepository);
                IList<IPackage> dependents = dependentsWalker.GetDependents(package).ToList();
                if (dependents.Count > 0)
                {
                    ShowProgressWindow();
                    throw new InvalidOperationException(
                        String.Format(
                            CultureInfo.CurrentCulture,
                            Resources.PackageHasDependents,
                            package.GetFullName(),
                            String.Join(", ", dependents.Select(d => d.GetFullName()))
                        )
                    );
                }
            }

            var uninstallWalker = new UninstallWalker(
                LocalRepository,
                new DependentsWalker(LocalRepository),
                logger: NullLogger.Instance,
                removeDependencies: true,
                forceRemove: false)
                {
                    ThrowOnConflicts = false
                };
            IList<PackageOperation> operations = uninstallWalker.ResolveOperations(package).ToList();

            var uninstallPackageNames = (from o in operations
                                         where o.Action == PackageAction.Uninstall && !PackageEqualityComparer.IdAndVersion.Equals(o.Package, package)
                                         select o.Package.ToString()).ToList();

            bool? removeDependencies = false;
            if (uninstallPackageNames.Count > 0)
            {
                // show each dependency package on one line
                String packageNames = String.Join(Environment.NewLine, uninstallPackageNames);
                String message = String.Format(CultureInfo.CurrentCulture, Resources.Dialog_RemoveDependencyMessage, package)
                        + Environment.NewLine
                        + Environment.NewLine
                        + packageNames;

                removeDependencies = _userNotifierServices.ShowRemoveDependenciesWindow(message);
            }
            if (removeDependencies == null)
            {
                return removeDependencies;
            }

            bool hasScriptPackages;
            if (removeDependencies == true)
            {
                // if user wants to remove dependencies, we need to check all of them for PS scripts
                var scriptPackages = from o in operations
                                     where o.Package.HasPowerShellScript()
                                     select o.Package;
                hasScriptPackages = scriptPackages.Any();
            }
            else
            {
                // otherwise, just check the to-be-uninstalled package
                hasScriptPackages = package.HasPowerShellScript(new string[] { PowerShellScripts.Uninstall });
            }

            if (hasScriptPackages)
            {
                if (!RegistryHelper.CheckIfPowerShell2Installed())
                {
                    throw new InvalidOperationException(Resources.Dialog_PackageHasPSScript);
                }
            }

            return removeDependencies;
        }
开发者ID:xero-github,项目名称:Nuget,代码行数:79,代码来源:InstalledProvider.cs

示例3: AskRemoveDependencyAndCheckUninstallPSScript

        protected bool? AskRemoveDependencyAndCheckUninstallPSScript(
            IPackage package,
            IList<IPackageRepository> localRepositories,
            IList<FrameworkName> targetFrameworks)
        {
            Debug.Assert(localRepositories.Count == targetFrameworks.Count);

            var allOperations = new List<PackageOperation>();

            for (int i = 0; i < localRepositories.Count; i++)
            {
                var uninstallWalker = new UninstallWalker(
                    localRepositories[i],
                    new DependentsWalker(localRepositories[i], targetFrameworks[i]),
                    targetFrameworks[i],
                    logger: NullLogger.Instance,
                    removeDependencies: true,
                    forceRemove: false)
                    {
                        ThrowOnConflicts = false
                    };
                var operations = uninstallWalker.ResolveOperations(package);
                allOperations.AddRange(operations);
            }

            allOperations = allOperations.Reduce().ToList();

            var uninstallPackageNames = (from o in allOperations
                                         where o.Action == PackageAction.Uninstall && !PackageEqualityComparer.IdAndVersion.Equals(o.Package, package)
                                         select o.Package)
                                         .Distinct(PackageEqualityComparer.IdAndVersion)
                                         .Select(p => p.ToString())
                                         .ToList();

            bool? removeDependencies = false;
            if (uninstallPackageNames.Count > 0)
            {
                // show each dependency package on one line
                String packageNames = String.Join(Environment.NewLine, uninstallPackageNames);
                String message = String.Format(CultureInfo.CurrentCulture, Resources.Dialog_RemoveDependencyMessage, package)
                        + Environment.NewLine
                        + Environment.NewLine
                        + packageNames;

                removeDependencies = _userNotifierServices.ShowRemoveDependenciesWindow(message);
            }

            if (removeDependencies == null)
            {
                return removeDependencies;
            }

            bool hasScriptPackages;
            if (removeDependencies == true)
            {
                // if user wants to remove dependencies, we need to check all of them for PS scripts
                var scriptPackages = from o in allOperations
                                     where o.Package.HasPowerShellScript()
                                     select o.Package;
                hasScriptPackages = scriptPackages.Any();
            }
            else
            {
                // otherwise, just check the to-be-uninstalled package
                hasScriptPackages = package.HasPowerShellScript(new string[] { PowerShellScripts.Uninstall });
            }

            if (hasScriptPackages)
            {
                if (!RegistryHelper.CheckIfPowerShell2Installed())
                {
                    throw new InvalidOperationException(Resources.Dialog_PackageHasPSScript);
                }
            }

            return removeDependencies;
        }
开发者ID:nickfloyd,项目名称:NuGet,代码行数:77,代码来源:InstalledProvider.cs


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