For the latest documentation on Visual Studio 2017 RC, see Visual Studio 2017 RC Documentation.
Copies files to a new location in the file system.
The following table describes the parameters of the
Contains the items that were successfully copied.
Specifies the list of files to copy the source files to. This list is expected to be a one-to-one mapping with the list specified in the
Specifies the directory to which you want to copy the files. This must be a directory, not a file. If the directory does not exist, it is created automatically.
Overwrite files even if they are marked as read only files
Specifies how many times to attempt to copy, if all previous attempts have failed. Defaults to zero.
Note: The use of retries can mask a synchronization problem in your build process.
Specifies the delay between any necessary retries. Defaults to the RetryDelayMillisecondsDefault argument, which is passed to the CopyTask constructor.
Specifies the files to copy.
Warnings are logged, including:
DestinationFolder or the
DestinationFiles parameter must be specified, but not both. If both are specified, the task fails and an error is logged.
In addition to the parameters listed above, this task inherits parameters from the TaskExtension class, which itself inherits from the Task class. For a list of these additional parameters and their descriptions, see TaskExtension Base Class.
The following example copies the items in the
MySourceFiles item collection into the folder c:\MyProject\Destination.
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup> <MySourceFiles Include="a.cs;b.cs;c.cs"/> </ItemGroup> <Target Name="CopyFiles"> <Copy SourceFiles="@(MySourceFiles)" DestinationFolder="c:\MyProject\Destination" /> </Target> </Project>
The following example demonstrates how to do a recursive copy. This project copies all of the files recursively from c:\MySourceTree into c:\MyDestinationTree, while maintaining the directory structure.
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup> <MySourceFiles Include="c:\MySourceTree\**\*.*"/> </ItemGroup> <Target Name="CopyFiles"> <Copy SourceFiles="@(MySourceFiles)" DestinationFiles="@(MySourceFiles->'c:\MyDestinationTree\%(RecursiveDir)%(Filename)%(Extension)')" /> </Target> </Project>