user3564258
user3564258

Reputation: 3

manually associate changesets in tfs build

Microsoft TFS build by default assigns all changesets after last successful build into "Associated Changesets". Is there a way to do it manually? What I would like to achieve is to search for last build that has "Build Quality" set to Released.
So Each build would have associated all changesets after latest "Released" build. Is it possible?

Upvotes: 0

Views: 501

Answers (1)

Hamid Shahid
Hamid Shahid

Reputation: 4626

If you are using TFS 2012, the build workflow has an activity "Associate Changesets and Work Items" of type "Microsoft.TeamFoundation.Build.Workflow.Activities.AssociateChangesetsandWorkItems" which gets all the changesets and associate it with the build.

If you want to change that, you need to replace this activity with your custom workflow steps. I will leave the "finding the changesets" part to you but the following activity will allow you to associate the changesets with your build

namespace ContractLibrary
{
    using Microsoft.TeamFoundation.Build.Workflow.Activities;
    using Microsoft.TeamFoundation.Build.Workflow.Tracking;
    using System;
    using System.Activities;

    public class WriteAssociatedChangesets : CodeActivity
    {
        protected override void Execute(CodeActivityContext context)
        {
            if (context == null)
            {
                return;
            }

            this.WriteBuildInformation(context);
        }

        private void WriteBuildInformation(CodeActivityContext context)
        {
            var buildInformation = new WriteBuildInformation<AssociatedChangeset>()
            {
                Value = new AssociatedChangeset() { ChangesetId = 17997 /*Your ChangsetsID*/ }
            };

            context.Track(buildInformation);
        }
    }
}

The post is really useful in finding out how to write to build information.

Upvotes: 1

Related Questions