Team Build 工作流程无法加载我的自定义活动
我几个小时以来一直在寻找替代方案,但我发现了一些非常奇怪的情况。
因此,为了隔离我的问题,我创建了一个非常简单的代码活动,该活动位于我的 xaml 模板中:
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";
}
}
}
当我尝试在“在代理上运行”序列中运行此活动时,我收到了传统错误:
Cannot create unknown type '{clr-namespace:Weco.TeamBuild.FirmwareActivityPack;assembly=FirmwareActivityPack}TestActivity'.
我确实有包含 TestActivity 的程序集驻留在源代码管理中进行检查,并且我的构建控制器按照在线几篇文章中的建议指向它。
有趣的是,当我将该活动的副本放置在模板的最顶部时,它运行良好(但只有第一个 TestActivity)。看起来“自定义程序集的版本控制路径”仅对构建控制器有效,对代理无效。我试图避免在构建服务器的 GAC 中安装/卸载任何内容。
仅供参考,TFS 安装在 machine_1 上,Team Build(控制器 + 4 个代理)安装在 machine_2 上
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 unknown 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己找到了答案。
问题是构建失败时显示的错误消息过于笼统。我从构建控制器属性中清除了自定义程序集路径,并将该程序集安装在构建计算机的 GAC 上。
构建仍然失败,但现在显示不同的消息:
“构建过程验证失败。详细信息:验证错误:活动“1:DynamicActivity”的私有实现有以下验证错误:TF28001:活动“TestActivity”可以不能在 AgentScope 的上下文中使用。“
现在寻找答案很容易,解决方案是更改自定义活动的类属性,如下所示:
这就是诀窍。
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:
and that does the trick