-
Notifications
You must be signed in to change notification settings - Fork 30
Getting started with the RoboCopy activity
The RoboCopy activity can be used copy files between locations using the "Robust File Copy" command that has been standard within Windows since Vista. In this example we aim to show the basic steps that are required to get the activity integrated into a build.
Before you can make use of any of the TFS 2010 community build activities you have to make sure they are available for the build system and on your development PC. Instructions for this process can be found in the ALM Rangers build guide or in the getting started page of this wiki. This page assumes the VirtualPC is available in the developers build process workflow toolbox and that the Microsoft.VirtualPC.Interop.dll, TfsBuildExtensions.Activities.dll and TfsBuildExtensions.Activities.VirtualPC.dll are in your build systems CustomAssemblies folder (all these can be found in the community build activities distribution).
The RoboCopy activity is simple to use. Just drop it onto the build work flow and set, as a minimum, the
- Files property (which defaults to .)
- Source folder property (where to copy from)
- Destination folder properties (where to copy to)
Both of source and destination properties can be drive letters e.g c:\myfolder or UNC shares e.g. \server\share .
As with any other build activity, any of these properties can be set using fixed strings, build arguments or build variables as required.
Note: As with the other activities in this community project there is an Action property. However, for the RoboCopy activity it only has one option, Copy.
The RoboCopy command allows a wide variety of options to be passed to into the command to control logging, threading etc. To see a fully list at a command prompt run the command
RoboCopy /?
Any collection of these RoboCopy options can be passed in as string into the Options property.
If an error occurs, such as no access to a destination folder, then an error will be shown in the build log.
If no error occurs, by default no message will be shown. However, if the build logging level is set to detailed or above then the RoboCopy console output will be shown in the log, as well as the final return code
As well as the activity results being written into the build log, by using the ReturnCode property (of type integer) you can also make decisions within the build workflow based on the result of the RoboCopy activity. The possible return codes are as follows
ReturnCode | Message | Activity raise Build Error |
---|---|---|
0 | No errors occurred, and no copying was done. The source and destination directory trees are completely synchronized. | No |
1 | One or more files were copied successfully (that is, new files have arrived). | No |
2 | Some Extra files or directories were detected. Examine the output log. Some housekeeping may be needed. | No |
3 | One or more files were copied successfully (that is, new files have arrived). Some Extra files or directories were detected. Examine the output log. Some housekeeping may be needed. | No |
4 | Some Mismatched files or directories were detected. Examine the output log. Housekeeping is probably necessary. | No |
5 | One or more files were copied successfully (that is, new files have arrived). Some Mismatched files or directories were detected. Examine the output log. Housekeeping is probably necessary. | No |
6 | Some Extra files or directories were detected. Some Mismatched files or directories were detected. Examine the output log. Housekeeping is probably necessary. | No |
7 | One or more files were copied successfully (that is, new files have arrived). Some Extra files or directories were detected. Some Mismatched files or directories were detected. Examine the output log. Housekeeping is probably necessary. | No |
8 | Some files or directories could not be copied (copy errors occurred and the retry limit was exceeded). Check these errors further. | Yes |
9 | One or more files were copied successfully (that is, new files have arrived). Some files or directories could not be copied (copy errors occurred and the retry limit was exceeded). Check these errors further. | Yes |
10 | Some Extra files or directories were detected. Examine the output log. Some housekeeping may be needed. Some files or directories could not be copied (copy errors occurred and the retry limit was exceeded). Check these errors further. | Yes |
11 | One or more files were copied successfully (that is, new files have arrived). Some Extra files or directories were detected. Examine the output log. Some housekeeping may be needed. Some files or directories could not be copied (copy errors occurred) | Yes |
12 | Some Mismatched files or directories were detected. Examine the output log. Housekeeping is probably necessary. Some files or directories could not be copied (copy errors occurred and the retry limit was exceeded). Check these errors further. | Yes |
13 | One or more files were copied successfully (that is, new files have arrived). Some Mismatched files or directories were detected. Examine the output log. Housekeeping is probably necessary. Some files or directories could not be copied (copy errors occurred) | Yes |
14 | Some Extra files or directories were detected. Some Mismatched files or directories were detected. Examine the output log. Housekeeping is probably necessary. Some files or directories could not be copied (copy errors occurred and the retry limit was reached) | Yes |
15 | One or more files were copied successfully (that is, new files have arrived). Some Extra files or directories were detected. Some Mismatched files or directories were detected. Examine the output log. Housekeeping is probably necessary. | Yes |
16 | Serious error. RoboCopy did not copy any files. This is either a usage error or an error due to insufficient access privileges on the source or destination directories. | Yes |