Teamcity 和批处理文件
Teamcity and batch file
我目前正在尝试提取驻留在项目子文件夹中的 powershell
脚本。当我的 batch
文件运行时,它会尝试在项目中定位文件路径,但没有成功。
我首先尝试直接传递子文件夹,因为它在 Teamcity 中:
set file = "subFolder\myPowershell.ps1"
我第二次尝试拨打电话:
set file = %~dp0"subFolder\myPowershell.ps1"
然后我尝试了:
set file = %cd%"subFolder\myPowershell.ps1"
仍然没有成功。如何从 batch
文件获取 Teamcity
项目文件夹中此 powershell
脚本的路径?
这是您需要做的:
set file="%~dp0project sub folder\myPowershell.ps1"
注意:%~dp0
已经包含尾部反斜杠,因此不需要额外的斜杠。您还会注意到 set
命令中 =
的两边都没有 space 这也是必不可少的。
想通了。我必须在文件目录前加上 %1
前缀,然后 teamcity 会立即将其拾取。
set file="%1\subFolder\myPowershell.ps1"
感谢大家的抽空!
我目前正在尝试提取驻留在项目子文件夹中的 powershell
脚本。当我的 batch
文件运行时,它会尝试在项目中定位文件路径,但没有成功。
我首先尝试直接传递子文件夹,因为它在 Teamcity 中:
set file = "subFolder\myPowershell.ps1"
我第二次尝试拨打电话:
set file = %~dp0"subFolder\myPowershell.ps1"
然后我尝试了:
set file = %cd%"subFolder\myPowershell.ps1"
仍然没有成功。如何从 batch
文件获取 Teamcity
项目文件夹中此 powershell
脚本的路径?
这是您需要做的:
set file="%~dp0project sub folder\myPowershell.ps1"
注意:%~dp0
已经包含尾部反斜杠,因此不需要额外的斜杠。您还会注意到 set
命令中 =
的两边都没有 space 这也是必不可少的。
想通了。我必须在文件目录前加上 %1
前缀,然后 teamcity 会立即将其拾取。
set file="%1\subFolder\myPowershell.ps1"
感谢大家的抽空!