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 3454260
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:28:18+00:00 2026-05-18T09:28:18+00:00

i have wanted to copy the built files on my release built to a

  • 0

i have wanted to copy the built files on my release built to a local directory, not to an unc share. So i have written an activity which i wanted to do so:

    using System.Activities;
using System.IO;
using System.Linq;
using Microsoft.TeamFoundation.Build.Client;

namespace CustomBuiltActivities
{
    /// <summary>
    ///     This activity helps to copy a directory to another one. Integrated in TeamFoundation built activities are only supporting
    ///     copy to an unc share, so this is a small helper activity we need for copying files to an local directory.
    /// </summary>
    [BuildActivity(HostEnvironmentOption.Agent)]
    public sealed class CopyDirectoryLocal : CodeActivity
    {
        [RequiredArgument]
        public InArgument<string> DestinationDirectory { get; set; }

        [RequiredArgument]
        public InArgument<string> SourceDirectory { get; set; }

        protected override void Execute(CodeActivityContext context)
        {
            var destination = context.GetValue(DestinationDirectory);
            var source = context.GetValue(SourceDirectory);
            CopyRecursive(source, destination);
        }

        private static void CopyRecursive(string sourceDirectory, string destinationDirectory)
        {
            if (!Directory.Exists(sourceDirectory))
                throw new DirectoryNotFoundException(sourceDirectory);
            try
            {
                Directory.CreateDirectory(destinationDirectory);
            }
            catch
            {
            }
            Directory.GetDirectories(sourceDirectory).ToList().ForEach(
                sourceDir =>
                    {
                        var dirName = sourceDir.Substring(sourceDir.LastIndexOf("\\"));
                        CopyRecursive(sourceDir, destinationDirectory+"\\"+dirName);
                    });
            Directory.GetFiles(sourceDirectory).ToList().ForEach(
                sourceFile =>
                    {
                        var fileName = new FileInfo(sourceFile).Name;
                        File.Copy(sourceFile, string.Concat(destinationDirectory, "\\", fileName));
                    }
                );
        }
    }
}

But this activity fails and let me know that the directory was not found. How to fix it? I need customization by getting seperat folders in from the binaries manually out there.

Thx for help,
Michael Baarz

  • 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-18T09:28:19+00:00Added an answer on May 18, 2026 at 9:28 am

    Why do you not use a unc path based on localhost?

    \localhost\MyDir

    or even

    \localhost\c$\mydir

    If you want to proceed with your custom activity, it is pretty easy to debug. Execute the code in a unit test (or with eg a console app) with the specified values. Are you sure that the source directory exists when you start this activity? You could add some additional checks (such as Directory.Exists) in your code.
    You could also debug your code with http://www.ewaldhofman.nl/post/2010/10/01/Customize-Team-Build-2010-e28093-Part-12-How-to-debug-my-custom-activities.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have never written copy constructor, so in order to avoid pain i wanted
I wanted to copy files from a remote server, but it seems that the
I have a SQL Server 2008 database and I wanted to quickly copy all
Possible Duplicate: How does Copy-local work? I have following situation: there's a project named
I have a file on my computer that I wanted to copy into a
I have a DataSet populated from Excel Sheet. I wanted to use SQLBulk Copy
I am using Python to generate some XML files which are used by another
I have wanted to try GAE since launch, but coming from ASP .NET and
I am programming in Ruby and have wanted to learn about matrices but I
On occasion, I have wanted to push a closure onto ActionScript's event stack so

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.