Copy Task

A very common scenario for builds is copying a set of files from one place to another. How can we achieve this with MSBuild? There are several ways we will demonstrate in this chapter. Before we discuss how to copy the files, we’ll first take a close look at the Include statement of an item. I have created some sample files shown in the following tree, which we will use for the remainder of the chapter.

C:\Data\MSBuildExamples\Fundamentals
|
| ...
|
+---src
   |  one.txt
   |  two.txt
   |  three.txt
   |  four
   |
   +---sub
         sub_one.txt
         sub_two.txt
         sub_three.txt
         sub_four.txt

Previously, I said that three types of values can be contained in the Include declaration of an item. Those three are:

  1. A single value

  2. Multiple values separated by a ";"

  3. Declared using wildcards ...

Get Inside the Microsoft® Build Engine: Using MSBuild and Team Foundation Build now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.