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

  • Home
  • SEARCH
  • 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 8422301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:24:33+00:00 2026-06-10T03:24:33+00:00

I am currently working on a build definition for a TFS Implementation. I have

  • 0

I am currently working on a build definition for a TFS Implementation. I have almost everything working except i cannot get this last part to work.
Below is the CodeActivity class that I am currently implementing.

In the workflow diagram i am utilising the default associatedChangesets variable as the InArgument.

The following code works and creates the folder Database but the AssociatedChangesets does not seem to contain any items.

public sealed class CreateDatabaseDrop : CodeActivity
    {

        public InArgument<Workspace> Workspace { get; set; }
        public InArgument<string> DropLocation { get; set; }
        public InArgument<IList<Changeset>> AssociatedChangesets { get; set; }
        // If your activity returns a value, derive from CodeActivity<TResult>
        // and return the value from the Execute method.

        Workspace workspace;
        string dropLocation;
        IList<Changeset> associatedChangesets;
        protected override void Execute(CodeActivityContext context)
        {
            List<string> filesChanged = new List<string>();
            workspace = context.GetValue(this.Workspace);
            dropLocation = context.GetValue(this.DropLocation);
            associatedChangesets = context.GetValue(this.AssociatedChangesets);

            if (!Directory.Exists(dropLocation + @"\database\"))
                Directory.CreateDirectory(dropLocation + @"\database\");

            foreach (var c in associatedChangesets.OrderBy(x => x.CreationDate))
            {
                foreach (var change in c.Changes)
                {
                    context.WriteBuildMessage(change.Item.ServerItem);
                }
                foreach (var change in c.Changes.Where(x => x.Item.ItemType == ItemType.File && x.Item.ServerItem.Split('/').Last().ToLower().Contains(".sql")))
                {
                    string fileName = change.Item.ServerItem.Split('/').Last();
                    context.WriteBuildMessage(string.Format("SQL File Found: {0}", change.Item.ServerItem));
                    WorkingFolder wf = workspace.GetWorkingFolderForServerItem(change.Item.ServerItem);
                    string copyFrom = Path.Combine(wf.LocalItem, fileName),
                    copyTo = dropLocation + @"\database\" + fileName;
                    context.WriteBuildMessage(string.Format("Copying {0} to {1}", fileName, copyTo));
                    File.Copy(copyFrom, copyTo, true);
                }
            }
        }

Would anyone be able to help me figure out how to get All SQL changes since the last build was done.

  • 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-06-10T03:24:34+00:00Added an answer on June 10, 2026 at 3:24 am

    I eventually found how to do this. I will put most of the code below for future reference and people who run into the same problems.

        public sealed class CreateDatabaseDrop : CodeActivity
        {
            [RequiredArgument]
            public InArgument<Workspace> Workspace { get; set; }
            [RequiredArgument]
            public InArgument<IBuildDefinition> BuildDefinition { get; set; }
            [RequiredArgument]
            public InArgument<string> ProjectName { get; set; }
            Workspace workspace;
    
            protected override void Execute(CodeActivityContext context)
            {
                workspace = context.GetValue(this.Workspace);
                IBuildDefinition buildDef = context.GetValue(this.BuildDefinition);
                DateTime? comparison = null;
                var details = buildDef.QueryBuilds().Where(x => x.Status == BuildStatus.Succeeded).OrderBy(x => x.StartTime);
                if (details.Count() > 0)
                {
                    comparison = details.Last().StartTime;
                }
                if (!comparison.HasValue)
                {
                    return;
                }
                IEnumerable history = workspace.VersionControlServer.QueryHistory("$/" + context.GetValue(ProjectName),
                    VersionSpec.Latest,
                    0,
                    RecursionType.Full,
                    null,
                    new DateVersionSpec(comparison.Value),
                    VersionSpec.Latest,
                    Int32.MaxValue,
                    true,
                    false);
    
                foreach (Changeset c in history.OfType<Changeset>().OrderBy(x => x.CreationDate))
                {
                    foreach (var change in c.Changes.Where(x => x.Item.ItemType == ItemType.File
                        && x.Item.ServerItem.Split('/').Last().ToLower().Contains(".sql")
                        && (x.ChangeType != (ChangeType.Delete | ChangeType.SourceRename | ChangeType.Rename))))
                    {
                        string fileName = change.Item.ServerItem.Split('/').Last();
                        WorkingFolder wf = workspace.TryGetWorkingFolderForServerItem(change.Item.ServerItem);
                        if (wf != null && !string.IsNullOrEmpty(wf.LocalItem))
                        {
                            context.WriteBuildMessage(string.Format("SQL File found: {0}", fileName));
    
                        }
                    }
                }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The project I'm currently working on generates 30+ warnings each time it gets build.
Currently I'm working on Text to speech in android and I'm trying to build
We are currently working on an instrumentation test suite which runs on our build
I am currently working on a Java EE project. I have successfully developed a
I am currently working on a custom SharePoint web part (WSS 3.0, not MOSS)
I'm working on trying to have my project automatically build two different versions of
I'm currently working on a build system in Phing that takes a Zend Framework
I'm currently working on a UDP socket application and I need to build in
Iam currently working on a iPad project where i build my code on top
I'm currently working on a Java project which uses Tibco rendezvous control. I have

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.