Team Build workflow can't load my custom activity
I've been searching for alternatives for hours, and I got some really weirdness going on.
So to isolate my problem, I created a very simple code activity that goes inside my xaml template:
using System.Activities;
using Microsoft.TeamFoundation.Build.Client;
using Microsoft.TeamFoundation.Build.Workflow.Activities;
namespace Weco.TeamBuild.FirmwareActivityPack
{
[BuildActivity(HostEnvironmentOption.Controller)]
public sealed class TestActivity: CodeActivity<string>
{
protected override string Execute(CodeActivityContext context)
{
context.TrackBuildMessage("Inside TestActivity", BuildMessageImportance.High);
return "success";
}
}
}
When I tried to run this activity inside the "Run on Agent" sequence, I got the traditional error:
Cannot create 开发者_StackOverflowunknown type '{clr-namespace:Weco.TeamBuild.FirmwareActivityPack;assembly=FirmwareActivityPack}TestActivity'.
I do have the assembly where the TestActivity resides checked in source control, and my build controller points to it as recommended in several articles online.
The interesting factor is that when I place a copy of that activity at the very top of my template, it runs fine (but only the first TestActivity). It looks like the "Version Control Path to Custom Assemblies" is only valid for the build controller, and not for the agents. I'm trying to avoid having to install/uninstall anything in my build server's GAC.
FYI, TFS is installed on machine_1, and Team Build (controller + 4 agents) is installed on machine_2
Found the answer myself.
The problem is that the error message displayed when the build fails is too generic. I cleared the custom assembly path from the build controller properties and installed the assembly on the build machine's GAC.
The build still failed, but now with a different message:
"The build process failed validation. Details: Validation Error: The private implementation of activity '1: DynamicActivity' has the following validation error: TF28001: Activity 'TestActivity' can not be used in the context of an AgentScope. "
Now searching for the answer was easy, and the solution is to change the class attribute for your custom activity as follow:
[BuildActivity(HostEnvironmentOption.Agent)]
public sealed class UpdateFirmwareVersionBeforeCompiling : CodeActivity<string>
and that does the trick
精彩评论