.net - TFS 2010 自定义构建事件 TF215097 错误

标签 .net build-automation

对于 TFS 2010 中的构建过程,我创建了一个包含一些自定义代码事件的库。
在过去,通过将库 (*.dll) 添加到源代码管理并将“构建 Controller - 自定义程序集的版本控制路径”设置为可以在源代码管理中找到库的路径,一切都很好。

但是几天后(我一直在更新库),构建不再成功。
报告的错误是:

TF215097: An error occurred while initializing a build for build definition "Cannot create unknown type '{clr-namespace:BuildTasks;assembly=BuildTasks}'"



searching除了将库安装到 GAC 之外,我找不到任何其他解决方案。这行得通,但我想知道为什么在不必安装到 GAC 的情况下就不可能让它工作。

因此,尽管它现在又可以正常工作了,但我还是希望它可以在没有 GAC 的情况下以旧方式重新工作。希望你们中的一些人可以帮助我。提前致谢。

最佳答案

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

  • 将您的自定义事件构建到
    您的工作流程。
  • 确保您的
    顶部的 xmlns 已定义
    正确:
    xmlns:local="clr-namespace:BuildTasks;assembly=BuildTasks"
  • 确保 XAML 中的标签用于
    构建过程具有本地(或
    无论您使用什么前缀)
    正确。
  • 将更新的工作流 XAML checkin 团队项目并更新构建定义。
  • 在您的团队项目中创建一个名为“CustomBuildAssemblies”的新目录
  • 转到您用于创建自定义构建任务的项目的 bin/Debug(或发布)文件夹(基本上是获取您放入 GAC 中的 dll)并将其放入步骤 5 中创建的目录中。
  • 通过转至 Team Exporer,选择您要执行此操作的项目,将项目列表展开并右键单击“Builds”,然后选择“Manage Build Controllers”,告诉构建 Controller 在哪里查找自定义程序集。选择 Controller (应该是列表中的第一件事)并单击属性。将版本控制路径设置为在步骤 5 中创建的目录(位于弹出窗口的中间)。

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

    希望这会帮助你。我也花了一些时间来弄清楚这一点。如果我需要更详细地说明这一点,请告诉我。我希望我可以发布一些对话框的屏幕截图。

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

    我使用 T4 模板并在构建程序集之前运行它。它在读取 checkin 的自定义事件 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 或类似的东西)。

    关于.net - TFS 2010 自定义构建事件 TF215097 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2910983/

    相关文章:

    c# - 如何使 String.Contains 不区分大小写?

    silverlight - 在没有 Visual Studio 2010 的情况下安装 Silverlight 4 Toolkit(用于构建服务器)

    c# - 什么是表示多个集合的数据结构?

    .net - DDay.iCal Outlook 与时区和重复模式的兼容性

    c# - .Net/C# 构建工具 - NAnt 是首选工具吗?

    powershell - PSake 扩展?

    deployment - LESS 部署和构建自动化

    automation - 如何以便宜/免费的方式设置构建服务器?

    c# - 在类似 eBay 的系统中使用的最佳搜索引擎 (.NET)

    c# - 一个变量如何同时有两个值?