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 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 StyleCop 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).

Basic Usage

image

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.

image

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.

Adding Options

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.

Error Handling and Logging

If an error occurs, such as no access to a destination folder, then an error will be shown in the build log.

image

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

image

 

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

Last edited Dec 15, 2011 at 10:21 PM by rfennell, version 2

Comments

No comments yet.