-
Notifications
You must be signed in to change notification settings - Fork 30
Getting started with the AssemblyInfo activity
The AssemblyInfo activity allows you to get and set the properties in one or more AssemblyInfo.cs files.This activity should be used prior to building the projects in a build workflow, it edits the files on the build agent PC. 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 AssemblyInfo activity is available in the developers build process workflow toolbox.
The following workflow should be built at the end of the ‘Initialize Workspace’ sequence
The first step is find the Get Workspace activity in your build process, this is where the files are pulled from the TFS server to the local build agents workspace. After this activity add a FindMachingFiles activity (from the Team Foundation Build Activities tab in the toolbox). In the workflow above it has the display DisplayName of “Find the AssemblyInfo files”. As the name suggests this activity is used to find all the assemblyinfo.cs files in the build we will be editing.
The result of this find is stored in a workflow variable AssemblyInfoFiles. This should to be created with a type of IEnumerable; it’s scope, in the default workflow, was set to Initialize workspace. Once the variable was created the activities output can be assigned to it
Note This sample only looks for .CS files, you can have a build that looks for assemblyinfo.* hence picking up .CS, .VB and .FS version within the same solution. In this case the edits would be applied to all assemblyinfo files that match the find files criteria
It is useful to list the files that will be updated in the build log. To do this add a ForEach activity (from control flow tab in toolbox) that returns each file name (string) in the FileToVersion collection variable and logs them via a WriteBuildMessage (from the Team Foundation Build Activities tab in the toolbox). This is set to High importance to make sure it appears in the log.
Next add the AssemblyInfo activity (from whichever tab it was added to in toolbox). As a minimum you need to set the Files property to the list of AssemblyInfo files previously found and at least one other property you wish to reset. You can of course update as many as you wish with a single instance of the activity.
The following is a list of the properties available. Note that many allow use the tokens to allow the updating of current values
Property | Direction | Comment |
---|---|---|
Files | InArgument<IEnumerable> [Required] | Sets the AssemblyInfo files to update |
AssemblyVersion | InArgument | Setting the value to null will disable updating this attribute. The following tokens are supported $(current) $(increment) $(date:) e.g. “$(current) .$(current).$(increment).$(date:yyyy)“ |
AssemblyFileVersion | InArgument | Setting the value to null will disable updating this attribute. The following tokens are supported $(current) $(increment) $(date:) |
AssemblyInformationalVersion | InArgument | Setting the value to null will disable updating this attribute. The following tokens are supported $(version) $(fileversion) $(date:) |
AssemblyCompany | InArgument | Setting the value to null will disable updating this attribute. The following tokens are supported $(version) $(fileversion) $(date:) |
AssemblyConfiguration | InArgument | Setting the value to null will disable updating this attribute. The following tokens are supported $(version) $(fileversion) $(date:) |
AssemblyCopyright | InArgument | Setting the value to null will disable updating this attribute. The following tokens are supported $(version) $(fileversion) $(date:) |
AssemblyCulture | InArgument | Setting the value to null will disable updating this attribute |
AssemblyDelaySign | InArgument<bool?> | Setting the value to null will disable updating this attribute. Set to true to mark the assembly for delay signing. |
AssemblyDescription | InArgument | Setting the value to null will disable updating this attribute. The following tokens are supported $(version) $(fileversion) $(date:) |
Guid | InArgument<System.Guid?> | Sets the assembly GUID. Setting the value to null will disable updating this attribute. |
AssemblyKeyFile | InArgument | Sets the key file to use to sign the assembly. Setting the value to null will disable updating this attribute. |
AssemblyKeyName | InArgument | Sets the name of a key container within the CSP containing the key pair used to generate a strong name. Setting the value to null will disable updating this attribute |
AssemblyProduct | InArgument | Setting the value to null will disable updating this attribute. The following tokens are supported $(version) $(fileversion) $(date:) |
AssemblyTitle | InArgument | Setting the value to null will disable updating this attribute. The following tokens are supported $(version) $(fileversion) $(date:) |
AssemblyTrademark | InArgument | Setting the value to null will disable updating this attribute. The following tokens are supported $(version) $(fileversion) $(date:) |
CLSCompliant | InArgument<bool?> | Set to true to mark the assembly CLS compliant. Setting the value to null will disable updating this attribute. |
ComVisible | InArgument<bool?> | Set to true to mark the assembly ComVisible . Setting the value to null will disable updating this |
MaxAssemblyVersion | OutArgument | Gets the max computed version |
MaxAssemblyFileVersion | OutArgument | Gets the max computed version |
MaxAssemblyInformationalVersion | OutArgument | Gets the max computed version |
AssemblyVersions | OutArgument<IEnumerable> | Gets the updated assembly version |
AssemblyFileVersions | OutArgument<IEnumerable> | Gets the updated assembly version |
AssemblyInformationalVersions | OutArgument<IEnumerable> | Gets the updated assembly version |
The following tokens are supported for replacement (all tokens are not supported by every property, see properties comments for the list of supported tokens):
The general usage for tokens is as follows
To build the [Major], [Minor], [Release] or [Build] values in a version number e.g. AssemblyVersion = “$(current) .$(current).$(increment).$(date:yyyy)“
To build a string based property e.g. AssemblyTitle="The version is
Token | Description |
---|---|
$(current) | Uses the current value i.e the current integer value for one of the[Major], [Minor], [Release] or [Build] values in a version number |
$(increment) | Uses an incremented value i.e the current integer value plus one for one of the[Major], [Minor], [Release] or [Build] values in a version number |
$(date:) | Uses the current date formatted with the specified standard date formatting string for one of the[Major], [Minor], [Release] or [Build] values in a version number, note the result must be an integer if being used to build a version number, but can be any string format if being used in a string based property |
$(version) | The updated AssemblyVersion value |
$(fileversion) | The updated AssemblyFileVersion value |
Running
Save the edited build process template and create a build using it. if you chose to expose any of the new activity properties out via a build arguments you should set these prior to running the build. Once this is done the build can be run and you should be able to see your changes to the assembly properties
When the build runs it should show the generated version number in the log and the built assemblies should have the version details expected.