Team Foundation Build workflow provides Copy Directory activity to copy the folder content but its doesn’t have an activity to copy the files. If you need to copy files as part of the build process then you have below options.
- Write a custom activity for copying files
- use Invoke Process activity to call the xcopy or robocopy commandline tools
In this post, I will show the steps to copy a file using Invoke Process activity and xcopy command.
First, you need to drag and drop the InvokeProcess activity from toolbox to the workflow template.
This activity contains below properties.
FileName (String): FileName of the process that you want to start.
Arguments (String): Command-line arguments that you want to pass to the process.
EnvironmentVariables (IDictionary<TKey, TValue><String,String>): Additional environment variables and their values.
OutputEncoding (Encoding): Encoding that is used to read the output and error streams. Default value will work for scenerios.
WorkingDirectory (String): You can specify the working directory (WorkingDirectory) in which you want to run the process.
Result(Int32): Returns the ExitCode from the process.
For the copy file activity, here are the sample values for above properties.
Additionally, Inside the InvokeProcess activity you need to add two activities to display the standard output and error output from your process
WriteBuildMessage activity: This activity should be added under Standard Output, and its property should be set to stdOutput.
WriteBuildError activity: This should be added under Handle Standard Output, and its property should be set to errOutput.