Search code examples
tfstfsbuildbuild-process

TFS Online - Dont Zip empty folder


We're using TFS-Online to One-Click-Deploy our Software.

From time to time it happens, that we need to use some special scripts, we store in a folder. This basically means, most of the time said folder stays empty.

If i now go and trigger a build, i have there followings tasks

Zip task

Now the question:

Is there any way to suppress these two tasks if the folder to be zipped/deleted is empty?

The tasks are the built in ones.

Note: This is NO on-premise TFS


Solution

  • You could specify conditions for running a task in VSTS. Express the condition as a nested set of functions. The agent evaluates the innermost function and works its way out. The final result is a boolean value that determines if the task is run or not.

    In your case, a solution should be:

    • Add a powershell task prior to the Archive Files task.
    • Use the powershell task to judge the folder is empty or not.
    • If the folder is empty then fail the powershell task.(Remember to check Continue on error or always run option)
    • Add a condition for both Archive File and Delete File task such as Only when all previous tasks have succeeded

    After this, those two task will not run when the special folder is empty during the build pipeline.

    More details please refer this thread Specify conditions for running a task.