title | description | ms.topic | ms.prod | ms.technology | ms.assetid | ms.manager | ms.author | author | ms.date | monikerRange |
---|---|---|---|---|---|---|---|---|---|---|
Copy Files | VSTS or Team Foundation Server |
Learn how you can copy files between folders with match patterns when building code in VSTS and Team Foundation Server TFS |
reference |
devops |
devops-cicd |
BB8401FB-652A-406B-8920-4BD8977BFE68 |
douge |
alewis |
andyjlewis |
08/10/2016 |
>= tfs-2015 |
[!INCLUDE temp]
Copy files from a source folder to a target folder using match patterns.
None
::: moniker range="vsts"
[!INCLUDE temp]
::: moniker-end
[!INCLUDE [temp](../_shared/control-options-arguments.md)]Argument | Description |
---|---|
Source Folder |
Folder that contains the files you want to copy. If you leave it empty, the copying is 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 copy files from the directory created for the definition. |
Contents | Specify match pattern filters (one on each line) that you want to apply to the list of files to be copied. For example:
The pattern is used to match only file paths, not folder paths. So you should specify patterns such as ```**\bin\**``` instead of of ```**\bin```. More examples are shown below. |
Target Folder | Folder where the files will be copied. In most cases you specify this folder using a variable. For example, specify ```$(Build.ArtifactStagingDirectory)``` if you intend to [publish the files as build artifacts](../../build/artifacts.md). |
Advanced | |
Clean Target Folder | Select this check box to delete all existing files in the target folder before beginning to copy. |
Over Write | Select this check box to replace existing files in the target folder. |
You want to copy just the readme and the files needed to run this C# console app:
`-- ConsoleApplication1
|-- ConsoleApplication1.sln
|-- readme.txt
`-- ClassLibrary1
|-- ClassLibrary1.csproj
`-- ClassLibrary2
|-- ClassLibrary2.csproj
`-- ConsoleApplication1
|-- ConsoleApplication1.csproj
On the Variables tab, $(BuildConfiguration)
is set to release
.
-
Source Folder:
$(Build.SourcesDirectory)
-
Contents (example of multiple match patterns):
ConsoleApplication1\ConsoleApplication1\bin\**\*.exe ConsoleApplication1\ConsoleApplication1\bin\**\*.dll ConsoleApplication1\readme.txt
-
Contents (example of OR condition):
ConsoleApplication1\ConsoleApplication1\bin\**\?(*.exe|*.dll) ConsoleApplication1\readme.txt
-
Contents (example of NOT condition):
ConsoleApplication1\**\bin\**\!(*.pdb|*.config) !ConsoleApplication1\**\ClassLibrary*\** ConsoleApplication1\readme.txt
-
Target Folder:
$(Build.ArtifactStagingDirectory)
These files are copied to the staging directory:
`-- ConsoleApplication1
|-- readme.txt
`-- ConsoleApplication1
`-- bin
`-- Release
| -- ClassLibrary1.dll
| -- ClassLibrary2.dll
| -- ConsoleApplication1.exe
[!INCLUDE include]
[!INCLUDE temp]
[!INCLUDE temp]
::: moniker range="< vsts" [!INCLUDE temp] ::: moniker-end