Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5979269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:38:08+00:00 2026-05-22T21:38:08+00:00

I need to add a custom activity to the default workflow template to increase

  • 0

I need to add a custom activity to the default workflow template to increase assembly versions at the earliest point possible in the build process.

What I would like to achieve is to create and map the exact same workspace (that is be created further down in the workflow) inside my custom activity so that I can check out an xml file, increase the version number held within, write it back to the xml file and check the xml file back in.

I’m aware that this workspace will be created later on in the workflow but that will be too late in the build process for what I’m trying to achieve, so instead of moving any of the activities or duplicating them in a position above my custom activity (this should be ok as this workspace will be deleted and recreated again later)

I think the details I need are the BuildDirectory, WorkspaceName and SourcesDirectory. Can anyone tell me how to achieve the creation of the workspace or how obtain this data in code?

the build will be carried out on a build server, and I am using TFS 2010 and c#.

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:38:08+00:00Added an answer on May 22, 2026 at 9:38 pm

    I followed the series of blog articles by Ewald Hofman 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:

    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<VersionControlServer>();
    
            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;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I Need add custom values to AppSettings in a webservice i have this code,
I have a need to add custom HTML attributes, specifically classes or styles to
When I need to add a custom page to a WordPress-based site, I always
I need to add some methods to the delegate protocol of my custom UITextField
I need to add custom validation(I think) for validating input from an user. Here's
I need to add a custom field with the fb:request-form tag in facebook. ie:-
I'm trying to add my custom activity indicator to my app. Since there are
do I need to add/modify anything here re memory management for a custom class?
I need some help with django request I want to add a custom form
I'm developing a web project where i need to add custom exception classes. For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.