TFS 2010 自定义生成活动 TF215097 错误
对于 TFS 2010 中的构建过程,我创建了一个包含一些自定义代码活动的库。 在过去,通过将库 (*.dll) 添加到源代码管理并将“构建控制器 - 自定义程序集的版本控制路径”设置为在源代码管理中可以找到库的路径,一切都可以正常工作。
但几天后(我经常更新库)构建不再成功。 报告的错误是:
TF215097:发生错误 初始化构建构建 定义“无法创建未知 类型“{clr-namespace:BuildTasks; assembly=BuildTasks}””
在 搜索 除了将库安装到 GAC 之外,我找不到任何其他解决方案。这可行,但我想知道为什么在不安装到 GAC 的情况下不可能让它工作。
因此,虽然它现在又可以工作了,但我希望在没有 GAC 的情况下恢复到原来的工作方式。提前致谢。
For the Build Process in TFS 2010 I've created a library containing some custom code activities.
In the past it all worked fine by adding the library (*.dll) to Source Control and setting the 'Build Controller - Version Control Path to Custom Assemblies' to the path where the library could be found in Source Control.
But since a few days (and I've been updating the library often) the build doesn't succeed anymore.
The error reported is:
TF215097: An error occurred while
initializing a build for build
definition "Cannot create unknown
type '{clr-namespace:BuildTasks;assembly=BuildTasks}'"
After searching I couldn't find any other solution than installing the library to the GAC. That works but I wonder why it is impossible to get it to work without having to install in to the GAC.
So although it working again now, I'd like to get it back to work the old way, without GAC. Hopefully some of you can help me. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(14)
我在这个帖子中的其他答案没有取得任何成功,但我想我会分享我所做的。我的自定义程序集已通过 GAC 加载到我的构建机器上。我必须手动打开构建模板 XAML 文件并将程序集添加到命名空间引用中。由于某种原因,Visual Studio 没有为我正确引用此内容。
之前:
在我的自定义构建任务程序集被称为ModifyTasks.dll之后
,将其替换为您自己的文件名...
I didn't have any success with the other answers in this thread however I thought I'd share what I did. My custom assembly was loaded onto my build machine through GAC. I had to manually open the build template XAML file and add my assembly to the namespace reference. For some reason Visual Studio wasn't properly referencing this for me.
Before:
After
My custom build task assembly is called ModifyTasks.dll replace it with your own file name...
重新启动 TFS 2012 构建服务器后,我遇到了同样的问题。运行完美的 CI 作业因上述 TF215097 错误而停止工作,无法找到自定义活动。
此页面上的评论 (https://social.msdn.microsoft.com/Forums/vstudio/en-US/479449e1-5c02-4744-b620-3bba64038cef/custom-build -activity-tf215097-cannot-create-unknown-type?forum=tfsbuild) 建议删除构建控制器配置中自定义活动 DLL 的设置源路径,保存更新的配置,重新添加相同的路径并再次节省。
这为我解决了这个问题。
I encountered the same issue after a reboot of our TFS 2012 build server. A CI job that was running perfectly fine stopped working with the mentioned TF215097 error, it was unable to find a custom activity.
A comment on this page (https://social.msdn.microsoft.com/Forums/vstudio/en-US/479449e1-5c02-4744-b620-3bba64038cef/custom-build-activity-tf215097-cannot-create-unknown-type?forum=tfsbuild) suggested removing the set source path to the custom activity DLLs in the build controller configuration, saving the updated configuration, re-adding the same path and saving again.
This fixed the issue for me.
如果要指定包含您编写的自定义代码活动的程序集,您需要执行以下操作:
您的工作流程。
顶部的 xmlns 已定义
正确:
xmlns:local="clr-namespace:BuildTasks; assembly=BuildTasks"
构建过程有本地(或
无论您使用什么前缀)
正确。
此时,您拥有一个自定义 XAML 工作流,该工作流正在引用(导入)已包含在源代码管理中的自定义程序集(或多个程序集)。构建控制器现在知道这些自定义程序集的位置。如果您需要添加/更新自定义构建任务,这允许您“签入”这些自定义程序集的新版本。
希望这会对您有所帮助。我也花了一些时间才弄清楚这一点。如果我需要更详细地说明这一点,请告诉我。我希望我可以发布一些对话框的屏幕截图。
更新:
我完全忘记了这个帖子,直到我看到它又复活了。我还可以更新这个答案,因为我找到了一种使 TFS 提取自定义构建任务程序集的最新版本的非常好的方法:为程序集创建唯一的版本号。
我使用 T4 模板并在构建程序集之前运行它。它在读取签入的自定义活动 DLL 后更新 AssemblyInfo.cs。
您会注意到,在底部我还为工作流程中使用的每个命名空间设置了 XML 命名空间定义。我发现生成的 XMAL 看起来更干净,它也有助于解决我的问题。
我将此文件创建为 AssemblyInfo.tt,并确保在构建程序集之前运行它(右键单击并选择运行 T4 或类似的内容)。
If you want to specify assemblies that contain custom code activities you've written you need to do the following:
your workflow.
xmlns at the top is defined
correctly:
xmlns:local="clr-namespace:BuildTasks;assembly=BuildTasks"
the build process have the local (or
whatever prefix you've used)
correctly.
At this point you have a custom XAML workflow that is referencing (importing) a custom assembly (or multiple ones) that have been included into source control. The build controller now knows where these custom assemblies are located. This allows you to "check in" new versions of those custom assemblies if you ever need to add/update your custom build tasks.
Hopefully this will help you out. It took me some time to figure this out as well. Let me know if I need to make this any more detailed. I wish I could post some screenshots of the dialogs.
UPDATE:
I completely forgot about this thread till I saw that it was revived. I can also update this answer as I've found a very good way of making TFS pull the latest version of your custom build task assembly: Making a unique version number for the assembly.
I use a T4 template and run it before I build the assembly. It updates AssemblyInfo.cs after reading the checked-in custom activity DLL.
You'll notice at the bottom I also setup XML namespace definitions for each of the namespaces that I use in the workflow. I've found that the generated XMAL looks much cleaner and it's also helped with my issues.
I created this file as AssemblyInfo.tt and just make sure I run it (right click and select run T4 or something like that) before building the assembly.
该解决方案可能不适用于所有情况,因为之前的帖子中提供的答案是正确的,但不是我的问题的解决方案。此答案假设以下条件:
我和(我怀疑许多其他人)正在做的是将他们的 xaml 工作流文档复制或链接到解决方案中,以便您可以使用工作流设计器和新的自定义程序集。嗯,这在 VS 设计器中效果很好,但是 VS 会用它自己的程序集引用来修改。例如,我有一个如下所示的参考:
使用我的项目解决方案编辑工作流程后,Visual Studio 将其更改为:
当您签入此文件进行测试或使用时,您现在将看到可怕的 TF215097 错误。
添加
; assembly=your.assemble
应该可以解决问题并消除将所有内容放入 GAC 中的需要。您可能还需要修复 xaml 文件其余部分中使用的名称空间引用。非常感谢:
http://msmvps.com/blogs/rfennell/archive/2010/03/08/lessons-learnt-building-a-custom-activity-to-run-typemock-isolator-in-vs2010-团队构建.aspx
This solution might not apply to all cases, as the answers provided in previous posts are correct, but were not the solution to my issue. This answer assumes the following:
What I and(I suspect many others) are doing is copying, or linking their xaml workflow documents into the solution so you can use the workflow designer and the new custom assemblies. Well, this works great in the VS designer, but VS will modify your assembly references with its own. For example I have a reference that looks like the following:
After editing the workflow with my project solution, visual studio changed that to:
When you check this file in to test or use, you will now see the dreaded TF215097 error.
Adding the
;assembly=your.assembly
should fix the problem and remove the need to put everything in the GAC. You might also need to fix the name space references using in the rest of the xaml file.BIG THANKS TO:
http://msmvps.com/blogs/rfennell/archive/2010/03/08/lessons-learnt-building-a-custom-activity-to-run-typemock-isolator-in-vs2010-team-build.aspx
您的 codeActivity 类需要此属性:
在其他地方,程序集未加载。
You need this attribute on your codeActivity class:
<BuildActivity(HostEnvironmentOption.All)> _
Elsewhere, the assembly is not loaded.
正如Rhapsody在2010年6月2日提到的,可以使用GAC。但需要注意的是,如果您确实使用了 GAC,则需要停止并重新启动构建服务,以便它重新扫描 GAC,从而拾取您的 DLL。
我最初在 GAC 中注册了我的 DLL,当我启动一个指向由我的自定义代码活动程序集组成的工作流的构建时,构建失败了。但是在停止并重新启动构建服务后,构建不会立即失败并出现可怕的“初始化构建定义 [BuildDefinitionName] 的构建时发生错误:无法创建未知类型...”。
As mentioned by Rhapsody on June 2 2010, the GAC can be used. However it needs to be noted that if you do use the GAC, you need to stop and restart the build service, so that it re-scans the GAC, hence picking up your DLL.
I had initially registered my DLL in the GAC, and when I kicked off a build that pointed to a workflow consisting of my custom code activity assembly, the build failed. But after stopping and restarting the build service, the build does not fail straight away with the dreaded "An error occurred while initializing a build for build definition [BuildDefinitionName] : Cannot create unknown type...".
这对我有用 - 程序集名称需要包含在自定义控件的命名空间声明中:
http://blogs.microsoft.co.il/blogs/royrose/archive/2010/06/09/custom-build-活动-and-tf215097-error.aspx
This worked for me -- the assembly name needs to be included in the namespace declaration for the custom control:
http://blogs.microsoft.co.il/blogs/royrose/archive/2010/06/09/custom-build-activities-and-tf215097-error.aspx
今天我没有找到这个问题的答案,所以这个答案对于你们中的一些人来说可能来得太晚了。
我真的被困在尝试从 GAC 做同样的事情,修改名称空间声明,并且我总是发现著名的“无法创建未知类型 '{clr-namespace:bla,bla,bla”。每次添加新程序集时修改所有构建模板是一种痛苦且烦人的经历。我在 GAC 中设置程序集时遇到了一些问题,似乎存在某种缓存,因为即使我从 GAC 卸载并重新安装程序集,自定义活动也不会刷新,
最后,我在 http://msdn.microsoft.com/en-us/library/ee330987.aspx 您可以添加具有自定义活动的自定义程序集,方法是将它们添加到源代码管理并在构建控制器属性中设置自定义程序集的控制路径(您可以从 Team Foundation Administration Console --> 构建配置 --> 控制器属性访问)
您只需添加您的程序集到源代码控制和 TFS 将处理一切。
I didn't find an answer to this problem up today, so probably this answer will arrive too late for some of you.
I was really stuck trying to do the same from GAC, modifying namespace declaration and i always was finding the famous "Cannot create unknown type '{clr-namespace:bla,bla,bla". Modifying all build templates each time you can add a new assembly is a painful and annoying experience. I've experienced some issues by setting assembly in GAC, it looks like there is some kind of cache because custom activities were not refreshed even if i uninstalled and reinstalled assembly from GAC,
Finally, I found in http://msdn.microsoft.com/en-us/library/ee330987.aspx that you can add custom assemblies with custom activities by adding them to Source Control and setting control path for custom assemblies in Build Controller Properties (you can access from Team Foundation Administration Console --> Build Configuration --> Controller Properties)
You Just need to add your assemblies to source control and TFS will take care about everything.
我有同样的问题。原因是我已经使用针对 x86 平台的自定义活动编译了库,并且构建控制器在 64 位 Windows 2008 VM 上运行。将目标平台切换到 AnyCPU 允许构建控制器立即利用该库,而无需将其添加到 GAC。
I had this exact same problem. The reason was that I had compiled the library with the custom activities against the x86 platform and the Build Controller was running off of a 64-bit Windows 2008 VM. Switching the target platform to AnyCPU allowed the build controller to immediately utilize the library without having to add it to the GAC.
我需要的修复是创建我的类的部分类定义,并将 BuildActivity 属性应用于它。我的问题是我的活动类上缺少 BuildActivity 属性,因为我是在松散的 Xaml 中实现它而不是作为代码活动,所以这为我修复了它。
据推测,Team Build 会加载包含带有 BuildActivity 或 BuildExtension 的类的任何程序集,理论上,这应该会导致所述程序集中的任何类都可用于构建。这将启用一种虚拟加载器类,该类允许加载 Xaml 活动,而无需这些部分类定义,但实际上这对我来说不起作用。
The fix I needed was to create a partial class definition of my class, and apply the BuildActivity attribute to it. My problem was that I was missing the BuildActivity attribute on my activity class, since I had implemented it in loose Xaml and not as a Code Activity, so this fixed it for me.
Supposedly, Team Build loads up any assembly containing a class with BuildActivity or BuildExtension on it, and in theory this should result in any class in said assembly being available to the build. This would have enabled a kind of dummy loader class that would allow loading of Xaml activities without needing these partial class definitions, but in practice that didn't work for me.
检查您的 Windows 事件通知。您的自定义活动 DLL 可能未正确加载。
如果没有,那么您可能必须将自定义活动项目的平台目标更改为 32 位或 64 位。
Check your Windows Event notifications. Your custom activity DLL may NOT have gotten loaded properly.
If it did not, then you may have to change the platform target of your custom activity project... either to 32bit or 64 bit.
由于没有给出答案,而且我也没有找到任何解决办法,所以我决定现在将其提交给 GAC。
这也有效。 :)
Since no answer is given and I haven't found any fix, I decided to put in the GAC now.
That works as well. :)
上面提到的属性是:
一般来说,TF215097 似乎确实可以意味着“你的东西坏了”而不仅仅是“我找不到它”。
The Attribute mentioned above is:
In general, it really seems like TF215097 can mean "you're stuff is broken" not just "I couldn't find it".
如果您错误地混合了不同版本 TFS 的构建扩展,则此错误的另一个来源。例如,如果您使用的是 TFS 2012,但尝试使用 TFS 2013 构建扩展< /a> 你会得到这个错误。
Another source of this error if you by mistake mix build extensions for different versions of TFS. For instance if you are using TFS 2012 but try to use TFS 2013 build extensions you will get this error.