Utility: Delete files

Last Update: 9/26/2016

Team Services | TFS 2017 | TFS 2015 Update 3 | Previous versions (XAML builds)

Delete files or folders.

Demands

None

Arguments

Argument Description
Source Folder

Folder that contains the files you want to delete. If you leave it empty, the deletions are done from the root folder of the repo (same as if you had specified $(Build.SourcesDirectory)).

If your build produces artifacts outside of the sources directory, specify $(Agent.BuildDirectory) to delete files from the build agent working directory.

Contents

Specify minimatch pattern filters (one on each line) that you want to apply to the list of files to be deleted. For example:

  • ** deletes all files and folders in the root folder.
  • temp deletes the temp folder in the root folder.
  • temp* deletes any file or folder in the root folder with a name that begins with temp.
  • **\temp\** deletes all files in any sub-folder named temp.
  • **\temp* deletes any file or folder with a name that begins with temp.
  • **\temp*\** deletes files in any sub-folder that begins with the name temp.
Control options

Q & A

Q: What's a minimatch pattern? How does it work?

A: See:

Q: I'm having problems. How can I troubleshoot them?

A: Try this:

  1. On the variables tab, add system.debug and set it to true. Select to allow at queue time.

  2. In the explorer tab, view your completed build and click the build step to view its output.

The control options arguments described above can also be useful when you're trying to isolate a problem.

Q: How do variables work? What variables are available for me to use in the arguments?

A: $(Build.SourcesDirectory) and $(Agent.BuildDirectory) are just a few of the variables you can use. See Variables.

Do I need a build agent?

You need at least one agent to run your build. Get an agent.

I can't select a default agent queue and I can't queue my build. How do I fix this?

See queues.

I use Team Foundation Server on-premises and I don't see some of these features. Why not?

Some of these features are available only on Visual Studio Team Services and not yet available on-premises. Some features are available on-premises if you have upgraded to the latest version of TFS.