locked
Cannot be used in the context of an AgentScope error message RRS feed

  • Question

  • I have just created a custom workflow activity and configured my Build Controller to pick up the compiled binary from my source control location.  However, I could not get the assembly to resolve correctly by simply placing it in source control.  I receive this error message:

    The build process failed validation. Details: Validation Error: The private implementation of activity '1: DynamicActivity' has the following validation error: TF28001: Activity 'GetBuildNumber' can not be used in the context of an AgentScope.

    This is the code that I have used in my custom workflow activity:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Activities;
    using Microsoft.TeamFoundation.Build.Client;
    
    namespace BuildTasks.Activities
    {
      [BuildActivity(HostEnvironmentOption.Controller)]
      public sealed class GetBuildNumber : CodeActivity<string>
      {
        [RequiredArgument]
        public InArgument<IBuildDetail> BuildDetail { get; set; }
    
        // If your activity returns a value, derive from CodeActivity<TResult>
        // and return the value from the Execute method.
        protected override string Execute(CodeActivityContext context)
        {
          IBuildDetail buildDetail = context.GetValue(this.BuildDetail);
          
          //return the build number
          return buildDetail.BuildNumber;
        }
      }
    }
    
    

     

    Please advise as to what I may be doing incorrectly which is resulting in this error message.

    Thanks.

    Friday, November 26, 2010 6:53 PM

Answers

  • Hi,

    To be able to run in the Agent Scope, the HostEnvironmentOption needs to be set to Agent like below. 

    [BuildActivity(HostEnvironmentOption. Agent)]

    I hope this helps,

    Mike


    blog - http://www.codesmartnothard.com
    • Marked as answer by vs2015junkie Monday, November 29, 2010 7:33 PM
    Saturday, November 27, 2010 1:56 AM

All replies

  • Hi,

    To be able to run in the Agent Scope, the HostEnvironmentOption needs to be set to Agent like below. 

    [BuildActivity(HostEnvironmentOption. Agent)]

    I hope this helps,

    Mike


    blog - http://www.codesmartnothard.com
    • Marked as answer by vs2015junkie Monday, November 29, 2010 7:33 PM
    Saturday, November 27, 2010 1:56 AM
  • Mike is correct, you have set the HostEnvironment to Controller, but it seems that you are using the activity within the RunOnAgent activity, e.g. in a Agent scope.

    Just a question, why do you have a custom activity to get the build number? You can just write BuildDetail.BuildNumber in your build process template to get the build number.

    /Jakob


    Blog: http://geekswithblogs.net/jakob Twitter: http://twitter.com/osirisjakob
    Saturday, November 27, 2010 11:57 PM