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


C# IPackage.FindCompatibleToolFiles方法代码示例

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


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

示例1: Execute

        public bool Execute(string installPath, string scriptFileName, IPackage package, Project project, FrameworkName targetFramework, ILogger logger)
        {
            string scriptPath, fullPath;
            if (package.FindCompatibleToolFiles(scriptFileName, targetFramework, out scriptPath))
            {
                fullPath = Path.Combine(installPath, scriptPath);
            }
            else
            {
                return false;
            }

            if (File.Exists(fullPath))
            {
                string toolsPath = Path.GetDirectoryName(fullPath);
                string logMessage = String.Format(CultureInfo.CurrentCulture, VsResources.ExecutingScript, fullPath);

                // logging to both the Output window and progress window.
                logger.Log(MessageLevel.Info, logMessage);

                IConsole console = OutputConsoleProvider.CreateOutputConsole(requirePowerShellHost: true);
                Host.Execute(console,
                    "[email protected](); $input|%{$__pc_args+=$_}; & " + PathHelper.EscapePSPath(fullPath) + " $__pc_args[0] $__pc_args[1] $__pc_args[2] $__pc_args[3]; Remove-Variable __pc_args -Scope 0",
                    new object[] { installPath, toolsPath, package, project });

                return true;
            }
            return false;
        }
开发者ID:njannink,项目名称:sonarlint-vs,代码行数:29,代码来源:PSScriptExecutor.cs

示例2: Execute

        public bool Execute(string installPath, string scriptFileName, IPackage package, Project project, FrameworkName targetFramework, ILogger logger)
        {
            string fullPath;
            IPackageFile scriptFile;
            if (package.FindCompatibleToolFiles(scriptFileName, targetFramework, out scriptFile))
            {
                fullPath = Path.Combine(installPath, scriptFile.Path);
            }
            else
            {
                return false;
            }

            return ExecuteCore(
                fullPath,
                installPath,
                package,
                project,
                targetFramework,
                logger,
                scriptFile);
        }
开发者ID:sistoimenov,项目名称:NuGet2,代码行数:22,代码来源:PSScriptExecutor.cs

示例3: ExecuteScript

        protected void ExecuteScript(
            string rootPath, 
            string scriptFileName, 
            IPackage package, 
            FrameworkName targetFramework,
            Project project)
        {
            string fullPath;
            IPackageFile scriptFile;
            if (package.FindCompatibleToolFiles(scriptFileName, targetFramework, out scriptFile))
            {
                fullPath = Path.Combine(rootPath, scriptFile.Path);
            }
            else
            {
                return;
            }
            
            if (File.Exists(fullPath))
            {
                if (project != null && scriptFile != null)
                {
                    // targetFramework can be null for unknown project types
                    string shortFramework = targetFramework == null ? string.Empty : VersionUtility.GetShortFrameworkName(targetFramework);

                    WriteVerbose(String.Format(CultureInfo.CurrentCulture, NuGetResources.Debug_TargetFrameworkInfoPrefix, 
                        package.GetFullName(), project.Name, shortFramework));

                    WriteVerbose(String.Format(CultureInfo.CurrentCulture, NuGetResources.Debug_TargetFrameworkInfo_PowershellScripts,
                        Path.GetDirectoryName(scriptFile.Path), VersionUtility.GetTargetFrameworkLogString(scriptFile.TargetFramework)));
                }

                var psVariable = SessionState.PSVariable;
                string toolsPath = Path.GetDirectoryName(fullPath);

                // set temp variables to pass to the script
                psVariable.Set("__rootPath", rootPath);
                psVariable.Set("__toolsPath", toolsPath);
                psVariable.Set("__package", package);
                psVariable.Set("__project", project);

                string command = "& " + PathHelper.EscapePSPath(fullPath) + " $__rootPath $__toolsPath $__package $__project";
                WriteVerbose(String.Format(CultureInfo.CurrentCulture, VsResources.ExecutingScript, fullPath));

                InvokeCommand.InvokeScript(command, false, PipelineResultTypes.Error, null, null);

                // clear temp variables
                psVariable.Remove("__rootPath");
                psVariable.Remove("__toolsPath");
                psVariable.Remove("__package");
                psVariable.Remove("__project");
            }
        }
开发者ID:sistoimenov,项目名称:NuGet2,代码行数:53,代码来源:ProcessPackageBaseCommand.cs

示例4: ExecuteScript

        protected void ExecuteScript(
            string rootPath, 
            string scriptFileName, 
            IPackage package, 
            FrameworkName targetFramework,
            Project project)
        {
            string scriptPath, fullPath;
            if (package.FindCompatibleToolFiles(scriptFileName, targetFramework, out scriptPath))
            {
                fullPath = Path.Combine(rootPath, scriptPath);
            }
            else
            {
                return;
            }
            
            if (File.Exists(fullPath))
            {
                var psVariable = SessionState.PSVariable;
                string toolsPath = Path.GetDirectoryName(fullPath);

                // set temp variables to pass to the script
                psVariable.Set("__rootPath", rootPath);
                psVariable.Set("__toolsPath", toolsPath);
                psVariable.Set("__package", package);
                psVariable.Set("__project", project);

                string command = "& " + PathHelper.EscapePSPath(fullPath) + " $__rootPath $__toolsPath $__package $__project";
                WriteVerbose(String.Format(CultureInfo.CurrentCulture, VsResources.ExecutingScript, fullPath));
                InvokeCommand.InvokeScript(command, false, PipelineResultTypes.Error, null, null);

                // clear temp variables
                psVariable.Remove("__rootPath");
                psVariable.Remove("__toolsPath");
                psVariable.Remove("__package");
                psVariable.Remove("__project");
            }
        }
开发者ID:themotleyfool,项目名称:NuGet,代码行数:39,代码来源:ProcessPackageBaseCommand.cs


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