Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I followed the series of blog articles by <a href="http://www.ewaldhofman.nl/post/2010/05/13/Customize-Team-Build-2010-e28093-Part-5-Increase-AssemblyVersion.aspx" rel="nofollow">Ewald Hofman</a> as a primer and created a custom activity that does the check-out, update and check-in of a GlobalAssemblyInfo file that I parse the current version from. My task is inserted at the top of the "Update Drop Location" which is right after it does the "Get the build" portion of the workflow. I just use require the IBuildDetail and a File Mask as arguments from which you can pull out the VersionControlServer to be able to access TFS. My code is below:</p> <pre><code>protected override string Execute(CodeActivityContext context) { // Obtain the runtime value of the input arguments. string assemblyInfoFileMask = context.GetValue(AssemblyInfoFileMask); IBuildDetail buildDetail = context.GetValue(BuildDetail); var workspace = buildDetail.BuildDefinition.Workspace; var versionControl = buildDetail.BuildServer.TeamProjectCollection.GetService&lt;VersionControlServer&gt;(); Regex regex = new Regex(AttributeKey + VersionRegex); // Iterate of the folder mappings in the workspace and find the AssemblyInfo files // that match the mask. foreach (var folder in workspace.Mappings) { string path = Path.Combine(folder.ServerItem, assemblyInfoFileMask); context.TrackBuildMessage(string.Format("Checking for file: {0}", path)); ItemSet itemSet = versionControl.GetItems(path, RecursionType.Full); foreach (Item item in itemSet.Items) { context.TrackBuildMessage(string.Format("Download {0}", item.ServerItem)); string localFile = Path.GetTempFileName(); try { // Download the file and try to extract the version. item.DownloadFile(localFile); string text = File.ReadAllText(localFile); Match match = regex.Match(text); if (match.Success) { string versionNumber = match.Value.Substring(AttributeKey.Length + 2, match.Value.Length - AttributeKey.Length - 4); Version version = new Version(versionNumber); Version newVersion = new Version(version.Major, version.Minor, version.Build + 1, version.Revision); context.TrackBuildMessage(string.Format("Version found {0}", newVersion)); return newVersion.ToString(); } } finally { File.Delete(localFile); } } } return null; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload