-
Notifications
You must be signed in to change notification settings - Fork 30
Getting started with the file activity
The file activity allows basic file attribute management operations to be performed by the build process. 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 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 file activity is available in the developers build process workflow toolbox.
Each instance of the file activity can perform one action. In this sample we will set the read only and system flags and alter the modified date on the DLLs produced by the build. To do this the file activity have been added twice at the end of the build process (as the last action in the agents sequence) as follows
The properties on each activity are set as follows
The possible actions and their related properties are as follows
Action | Description | Properties |
---|---|---|
AddAttributes | Adds an attribute to a file(s) | Required: Attributes, Files Attributes supported (with limitations as to what can be added or removed) * Archive * Compressed* * Encrypted* * Hidden * Normal* * ReadOnly * System *You can find the help topic for Win32's SetFileAttributes on MSDN As mentioned in this help topic, the SetFileAttributes API cannot be used to set any of the following file attributes: * FILE_ATTRIBUTE_COMPRESSED * FILE_ATTRIBUTE_DEVICE * FILE_ATTRIBUTE_DIRECTORY * FILE_ATTRIBUTE_ENCRYPTED * FILE_ATTRIBUTE_REPARSE_POINT * FILE_ATTRIBUTE_SPARSE_FILE |
These are special attributes that must be set through other means, like using the Win32 DeviceIoControl API, for example. | ||
GetChecksum | Gets the checksum of a file | Required: Path Output: Checksum |
GetTempFileName | Gets the path to the Windows temp file | Output: Path |
Move | Moves a file | Required: Path, TargetPath |
RemoveAttributes | Removes an attribute to a file(s) | Required: Attributes, Files See AddAttributes above |
Replace | Replaces files that machine a given expression | Required: RegexPattern Optional: Replacement, Path, TextEncoding, Files |
SetAttributes | Sets an attribute for a file(s) | Required: Attributes, Files See AddAttributes above |
Touch | Touches a file(s) so it access date is updated | Required: Files Optional: Force, Time |
Delete | Deleted a file(s) | Required: Files Optional: Force |
The activity properties are as follows
Property | Direction | Comment |
---|---|---|
Path | InOutArgument | A path to process or get. Use * for recursive folder processing. For the GetChecksum TaskAction, this indicates the path to the file to create a checksum for. |
RegexPattern | InArgument | Sets the regex pattern |
Replacement | InArgument | The replacement text to use. Default is string.Empty |
Files | InArgument<IEnumerable> | An ItemList of files to process. If calling SetAttributes, RemoveAttributes or AddAttributes, include the attributes in an Attributes metadata tag, separated by a semicolon. Note the Files property cannot contain wildcards. if you wish to use a wildcard you need to use a FileMatchingFile activity as used with the StyleCop activity |
TargetPath | InArgument | Sets the TargetPath for a renamed file |
Checksum | OutArgument | Gets the file checksum |
Force | InArguement | Forces the action on read only files |
Time | InArguement | Date and time to use for touch. If not specify, the activity will use the current date and time. |
When the build using this template is run (using a solution with two class library projects) we can see in the drops location that classlibrary1.dll has its attributes changed, and classlibrary2.dll has its modified date changed