本文整理汇总了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;
}
示例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);
}
示例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");
}
}
示例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");
}
}