我在我的FinalBuilder项目中添加了“执行PowerShell脚本”操作。手册说我可以使用以下语法访问FinalBuilder变量(在Specify Script区域输入):
$FBVariables.GetVariable("VarName")但问题是,在我的例子中,$FBVariables总是null,我的意思是下面的语句返回True
$FBVariables -eq $null我不知道我做错了什么。
发布于 2011-11-24 01:54:00
$FBVariables在Execute PowerShell Script操作中不可用。
您必须使用Run Script (我想在旧版本中使用Execute Script )操作,在Script Editor选项卡中将language设置为Powershell,在这里您可以使用#FBVariables
http://www.finalbuilder.com/Default.aspx?tabid=456&aft=9647#10952
发布于 2011-11-25 10:57:40
以下是LogVariables操作中包含的工作PowerShell脚本的示例。我发现不能对变量使用PowerShell操作,所以我使用了另一个操作,并添加了一个脚本来传入/传出Powershell Commandlet的信息。
Powershell脚本
Function ConvertNametoFolder([string]$FileName="VirtualServerInstanceName.web.config", [string]$FileSuffix="web.config")
{
[string]$Result = ""
if ($FileLen -ne "")
{
[int]$FileLen = $FileName.Length
[int]$SuffixLen = $FileSuffix.Length
$Result = $FileName
$Result = $FileName.SubString(0,($FileLen-$SuffixLen)-1)
# String join method (not safe)
#$Result = $Result + "\" + $FileSuffix
# .net Framework safe method for combining folder\file paths to Windows Standards.
$Result = [System.IO.Path]::Combine($Result, $FileSuffix)
}
Return $Result
}
$FileIn = $FBVariables.GetVariable("varWebConfigFilePath") # Passed-in at runtime
[string]$PathOut = ConvertNametoFolder $FileIn
$FBVariables.GetVariable("varIisSettingFile")
$FBVariables.SetVariable("varWebConfigFileDestinationPath", $PathOut)https://stackoverflow.com/questions/8245248
复制相似问题