有没有办法在TFS构建运行时检查构建目录中是否存在特定的.xml文件?
我试图根据找到/未找到的结果得到布尔结果true / false
您可以尝试编写脚本来检查特定文件是否存在,然后检查脚本并在构建过程中以Pre-build script
身份运行:
e.f.:
$Source = $Env:TF_BUILD_BUILDDIRECTORY
$filename = "*.xml"
if (!(Test-Path "$Source\$filename"))
{
Write-Warning "$filename absent from build directory"
# Write-Error "$filename absent from build directory"
#exit 1
}
参考Using Environment Variables in Visual Studio 2013 and TFS 2013
表达式编辑器使用标准VB.NET,因此您可以调用System.IO.File.Exists(path)
来检测文件是否已存在。