TFS 2010自定义生成活动TF215097错误

Rha*_*ody 16 .net build-automation tfs2010

对于TFS 2010中的构建过程,我创建了一个包含一些自定义代码活动的库.在过去,通过将库(*.dll)添加到源代码控制并将"构建控制器 - 自定义程序集的版本控制路径"设置为可在源代码管理中找到库的路径,一切正常.

但是几天之后(我经常更新库),构建不再成功.报告的错误是:

TF215097:初始化构建定义的构建时发生错误"无法创建未知类型"{clr-namespace:BuildTasks; assembly = BuildTasks}'"

搜索后,除了将库安装到GAC之外,我找不到任何其他解决方案.这有效,但我想知道为什么不必安装到GAC就无法工作.

因此,虽然它现在再次运行,但我希望在没有GAC的情况下以旧方式恢复工作.希望你们中的一些人可以帮助我.提前致谢.

Mik*_*e G 9

如果要指定包含您编写的自定义代码活动的程序集,则需要执行以下操作:

  1. 在您的工作流程中构建自定义活动.
  2. 确保正确定义了顶部的xmlns:xmlns:local ="clr-namespace:BuildTasks; assembly = BuildTasks"
  3. 确保构建过程的XAML中的标记正确具有本地(或您使用的任何前缀).
  4. 将更新的工作流XAML签入您的团队项目并更新您的构建定义.
  5. 在团队项目中创建一个名为"CustomBuildAssemblies"的新目录
  6. 转到用于创建自定义构建任务的项目的bin/Debug(或release)文件夹(基本上获取您放入GAC的dll)并将其放入步骤5中创建的目录中.
  7. 通过转到Team Exporer告诉构建控制器在哪里查找自定义程序集,选择要执行此操作的项目,展开项目列表并右键单击"构建",然后选择"管理构建控制器".选择控制器(应该是列表中的第一件事)并单击属性.将版本控制路径设置为在步骤5中创建的目录(位于弹出窗口的中间).

此时,您有一个自定义XAML工作流,它引用(导入)已包含在源代码管理中的自定义程序集(或多个).构建控制器现在知道这些自定义程序集的位置.如果您需要添加/更新自定义构建任务,这允许您"签入"这些自定义程序集的新版本.

希望这会帮助你.我花了一些时间才弄明白这一点.如果我需要更详细一点,请告诉我.我希望我能发布一些对话框的截图.

更新:我完全忘记了这个线程,直到我看到它恢复了.我也可以更新这个答案,因为我发现了一个非常好的方法,可以让TFS拉出最新版本的自定义构建任务程序集:为程序集创建一个唯一的版本号.

我使用T4模板并在构建程序集之前运行它.它在读取签入的自定义活动DLL后更新AssemblyInfo.cs.

<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="System.Xml.dll" #>
<#@ import namespace="System.Xml" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Reflection" #>
<#@ output extension=".cs" #>
<#

 //relative path to the DLL for your custom assembly in source control
 var filename = this.Host.ResolvePath("..\\..\\..\\..\\BuildAssemblies\\BuildTasks.dll");

 Version buildInfoAssemblyVersion = AssemblyName.GetAssemblyName(filename).Version;

 // Setup the version information. Using the DateTime object make it kinda unique
 var version = new Version(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, buildInfoAssemblyVersion.Revision + 1);

#>
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows.Markup;

// General Information about an assembly is controlled through the following 
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("BuildTasks")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("BuildTasks")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible 
// to COM components.  If you need to access a type in this assembly from 
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("feab7e26-0830-4e8f-84c1-774268727cbd")]

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Build and Revision Numbers 
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
// Version information is a combination of DateTime.Now and an incremented revision number coming from the file:
// <#= filename #>
[assembly: AssemblyVersion("<#= version.ToString() #>")]
[assembly: AssemblyFileVersion("<#= version.ToString() #>")]

[assembly: XmlnsDefinition("http://localhost/BuildTasks/Activities", "BuildTasks.Activities")]
[assembly: XmlnsDefinition("http://localhost/BuildTasks/Activities/InstallerA", "BuildTasks.Activities.InstallerA")]
[assembly: XmlnsDefinition("http://localhost/BuildTasks/Activities/InstallerB", "BuildTasks.Activities.InstallerB")]
[assembly: XmlnsDefinition("http://localhost/BuildTasks/Activities/CodeAnalysis", "BuildTasks.Activities.CodeAnalysis")]
[assembly: XmlnsDefinition("http://localhost/BuildTasks/Activities/Standards", "BuildTasks.Activities.Standards")]
[assembly: XmlnsDefinition("http://localhost/BuildTasks/Activities/CI", "BuildTasks.Activities.CI")]
[assembly: XmlnsDefinition("http://localhost/BuildTasks/Activities/Version", "BuildTasks.Activities.Version")]
Run Code Online (Sandbox Code Playgroud)

您会注意到,我还为工作流中使用的每个命名空间设置了XML命名空间定义.我发现生成的XMAL看起来更干净,它也有助于解决我的问题.

我创建了这个文件作为AssemblyInfo.tt,并确保我在构建程序集之前运行它(右键单击并选择运行T4或类似的东西).

  • Thansk的答复,但我完全按照你描述的方式完成了.一开始它也在工作,但突然停了下来.但我接受了解决方法; 通过将自定义代码活动程序集安装到GAC中,它可以正常工作.:)我没有时间搞清楚它现在有效. (3认同)

小智 8

此解决方案可能不适用于所有情况,因为之前帖子中提供的答案是正确的,但不是我的问题的解决方案.这个答案假设如下:

  1. 自定义解决方案程序集在签入时都已更改,并且已正确标记和构建.
  2. 已将构建控制器指向自定义程序集的正确源控制位置.

我和(我怀疑很多其他人)正在做的是复制或将他们的xaml工作流文档链接到解决方案中,以便您可以使用工作流设计器和新的自定义程序集.嗯,这在VS设计器中很有用,但是VS会用它自己修改你的程序集引用.例如,我有一个如下所示的引用:

xmlns:ca="clr-namespace:Custom.TFS.Activities;assembly=Custom.TFS.Activities" 
Run Code Online (Sandbox Code Playgroud)

使用我的项目解决方案编辑工作流后,visual studio将其更改为:

xmlns:local="clr-namespace:Custom.TFS.Activities" 
Run Code Online (Sandbox Code Playgroud)

当您检查此文件以进行测试或使用时,您现在将看到可怕的TF215097错误.

添加;assembly=your.assembly应该解决问题并删除将所有内容放入GAC的需要.您可能还需要在xaml文件的其余部分中修复名称空间引用.

非常感谢:http: //msmvps.com/blogs/rfennell/archive/2010/03/08/lessons-learnt-building-a-custom-activity-to-run-typemock-isolator-in-vs2010-team- build.aspx


小智 6

您需要在codeActivity类上使用此属性:

<BuildActivity(HostEnvironmentOption.All)> _

在其他地方,装配没有加载.


Rha*_*ody 0

由于没有给出答案,而且我也没有找到任何解决办法,所以我决定现在将其提交给 GAC。这也有效。:)