Rha*_*ody 16 .net build-automation tfs2010
对于TFS 2010中的构建过程,我创建了一个包含一些自定义代码活动的库.在过去,通过将库(*.dll)添加到源代码控制并将"构建控制器 - 自定义程序集的版本控制路径"设置为可在源代码管理中找到库的路径,一切正常.
但是几天之后(我经常更新库),构建不再成功.报告的错误是:
TF215097:初始化构建定义的构建时发生错误"无法创建未知类型"{clr-namespace:BuildTasks; assembly = BuildTasks}'"
搜索后,除了将库安装到GAC之外,我找不到任何其他解决方案.这有效,但我想知道为什么不必安装到GAC就无法工作.
因此,虽然它现在再次运行,但我希望在没有GAC的情况下以旧方式恢复工作.希望你们中的一些人可以帮助我.提前致谢.
如果要指定包含您编写的自定义代码活动的程序集,则需要执行以下操作:
此时,您有一个自定义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")]
您会注意到,我还为工作流中使用的每个命名空间设置了XML命名空间定义.我发现生成的XMAL看起来更干净,它也有助于解决我的问题.
我创建了这个文件作为AssemblyInfo.tt,并确保我在构建程序集之前运行它(右键单击并选择运行T4或类似的东西).
小智 8
此解决方案可能不适用于所有情况,因为之前帖子中提供的答案是正确的,但不是我的问题的解决方案.这个答案假设如下:
我和(我怀疑很多其他人)正在做的是复制或将他们的xaml工作流文档链接到解决方案中,以便您可以使用工作流设计器和新的自定义程序集.嗯,这在VS设计器中很有用,但是VS会用它自己修改你的程序集引用.例如,我有一个如下所示的引用:
xmlns:ca="clr-namespace:Custom.TFS.Activities;assembly=Custom.TFS.Activities" 
使用我的项目解决方案编辑工作流后,visual studio将其更改为:
xmlns:local="clr-namespace:Custom.TFS.Activities" 
当您检查此文件以进行测试或使用时,您现在将看到可怕的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
| 归档时间: | 
 | 
| 查看次数: | 10366 次 | 
| 最近记录: |