TFS Build: include the branch name in the assembly field of the build number

I would like to look at the assembly and quickly determine which branch it was built from.

How can I configure TFS Build to include the name of the current branch in the Build Number field (or a more appropriate field) of the assemblies being created?

+8
tfs versioning assemblies tfsbuild
source share
2 answers

Look at the task version at http://msbuildtasks.tigris.org/

This will allow you to update the assembly assembly.cs assembly.

This still leaves an “how” to identify the branch ...

You can devote one part of the major.minor.build.revision branch to the risk of religious debate on versioning. For example, major.minor simply follows your "external / commercial" version number, build is a TFS string type form, and version 1 points to your main branch, version 2 points to a specific branch. You can also use other assembly version attributes, such as AssemblyInformationalAttribute, to store the branch identifier in it.

I'm not completely updating how you can find the branch you're in, but in the worst case, it's just a matter of getting the current directory and applying some logic to display the branch name. The output of the tf branch. the command should also give you the branch name for the current workspace, but you will need a custom task to retrieve only the first row.

Not an answer to plug and play, but it can lead you in the right direction.

+4
source share

The version is simple in terms of getting it and updating the various AssemblyInfo.cs files.

I would streamline your TFS structure similarly to Subversion conventions, so you have a folder with baggage, tags, and branches.

Using a sequential naming convention, you can ensure that your specific MSBuild file always represents a given number of directories down or out of a trunk from a specific branch name.

Have a custom MSBuild task that will work for you (by navigating through the TFS folder hierarchy) and send this to your property, which is used to update AssemblyInformationalAttribute. You can use the FileUpdate task from http://msbuildtasks.tigris.org/ to perform Regex replacement in AssemblyInfo.cs files.

0
source share

Source: https://habr.com/ru/post/651271/


All Articles