Reputation: 21328
Is there a way to check if a specific .xml file exists in build directory when TFS build runs?
I'm trying to get a Boolean result true/false based on the result found/not found
I tried creating a variable that would store this result (I'm guessing that is the way to do it). However I get an error when trying to use it.
Upvotes: 0
Views: 2027
Reputation: 21328
Found the solution. I added a new variable "dcMatchedFile" - which is a IEnumerable type. Use this dcMatchedFile as "Result" option for FindMatchingFiles" item (see images below)
Then you can simply use "If" statement to check Any().
Upvotes: 0
Reputation: 114741
The expression editor uses standard VB.NET, so you can call into System.IO.File.Exists(path)
to detect whether a file already exists.
Upvotes: 0
Reputation: 30392
You can try writing a script to check if the specific file exist, then check in the script and run as Pre-build script
in your build process:
e.g.:
$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
}
Reference Using Environment Variables in Visual Studio 2013 and TFS 2013
Upvotes: 0