TFSBuild.proj 和导入外部目标 [英] TFSBuild.proj and Importing External Targets

查看:24
本文介绍了TFSBuild.proj 和导入外部目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们希望将覆盖的构建目标存储在外部文件中,并将该目标文件包含在 TFSBuild.proj 中.我们有一个核心设置步骤,并希望通过简单地将导入行添加到由向导创建的 TFSBuild.proj 来获得这些附加步骤.

We want to store our overridden build targets in an external file and include that targets file in the TFSBuild.proj. We have a core set steps that happens and would like to get those additional steps by simply adding the import line to the TFSBuild.proj created by the wizard.

<Import Project="$(SolutionRoot)/libs/my.team.build/my.team.build.targets"/>

我们不能对 $(SolutionRoot) 中的任何文件进行导入,因为在验证导入语句时,尚未从存储库中获取源.看起来 TFS 正在先拉下 TFSBuild.proj,没有任何其他文件.

We cannot have an import on any file in the $(SolutionRoot) because at the time the Import statement is validated, the source has not be fetched from the repository. It looks like TFS is pulling down the TFSBuild.proj first without any other files.

即使我们添加了条件导入,源代码管理中的版本如果存在也不会被导入.将导入磁盘上已存在的先前版本.

Even if we add a conditional import, the version in source control will not be imported if present. The previous version, already present on disk will be imported.

我们可以放弃将这些构建目标与我们的源代码一起存储,但它是移出源代码树的第一个依赖项,因此我们不愿意这样做.

We can give up storing those build targets with our source, but it is the first dependency to move out of our source tree so we are reluctant to do it.

有没有办法:

  1. 告诉 Team Build 再下拉几个文件,以便那些 Import 语句正确评估?
  2. 以一种除了 Import 之外的方式覆盖像 AfterCompile 这样的 Team Build 目标?
  3. 最终在 Team Build 中运行保留在其尝试构建的源下的构建目标?
  1. Tell Team Build to pull down a few more files so those Import statements evaluate correctly?
  2. Override those Team Build targets like AfterCompile in a manner besides the Import?
  3. Ultimately run build targets in Team Build that are kept under the source it's trying to build?

推荐答案

Team Build 有一个引导"阶段,其中 Team Build Configuration 文件夹(包含 TFSBuild.proj 的文件夹)中的所有内容都是从版本控制下载的.这是在构建代理调用 MSBuild.exe 告诉它运行 TFSBuild.proj 之前由构建代理执行的.

The Team Build has a "bootstrap" phase where everything in the Team Build Configuration folder (the folder with TFSBuild.proj) is downloaded from version control. This is performed by the build agent before the build agent calls MSBuild.exe telling it to run TFSBuild.proj.

如果您从 SolutionRoot 下移动您的目标文件并将其放置在 TFSBuild.proj 文件旁边的配置文件夹中,您将能够使用相对导入语句将其导入到您的 TFSBuild.proj 文件中,即

If you move your targets file from under SolutionRoot and place it in your configuration folder alongside the TFSBuild.proj file you will then be able to import it in your TFSBuild.proj file using a relative import statement i.e.

<Import Project="myTeamBuild.targets"/>

如果这些目标依赖于任何其他自定义 MSBuild 任务程序集,那么您也可以将它们与 TFSBuild.proj 文件放在同一文件夹中,并且您可以使用相对路径轻松引用它们.

If these targets rely on any additional custom MSBuild task assemblies then you can also have them in the same folder as your TFSBuild.proj file and you can reference them easily using a relative path.

请注意,在 TFS2008 中,构建配置文件夹默认位于 $/TeamProject/TeamBuildTypes 下,但是,它不必在那里.它实际上可以位于您的解决方案内的文件夹中 - 甚至可以是您的解决方案中专用于 Team Build 的项目.这有几个优点,包括使构建的分支更容易.因此,我的构建通常位于这样的文件夹中:

Note that in TFS2008, the build configuration folder defaults to being under $/TeamProject/TeamBuildTypes however, it does not have to be there. It can actually live in a folder that is inside your solution - and can even be a project in your solution dedicated to Team Build. This has several advantages including making branching of the build easier. Therefore I typically have my build located in a folder like this:

$/TeamProject/main/MySolution/TeamBuild

另请注意,默认情况下,在构建的引导阶段,构建代理只会下载构建配置文件夹中的文件,而不会向下递归到任何子文件夹.如果您希望它在引导阶段包含子文件夹中的文件,那么您可以在构建代理机器上的 tfsbuildserver.exe.config 文件的 appSettings 中设置以下属性(位于 %ProgramFiles%Visual Studio 9.0Common7IDEPrivateAssemblies)

Also note that by default, during the bootstrap phase of the build, the build agent will only download files that are in the build configuration folder and will not recurse down into any subfolders. If you wanted it to include files in subfolders during the bootstrap phase then you can set the following property in the appSettings of the tfsbuildserver.exe.config file on the build agent machines (located in %ProgramFiles%Visual Studio 9.0Common7IDEPrivateAssemblies)

<add key="ConfigurationFolderRecursionType" value="Full" />

请注意,如果您有多个构建代理,则必须记住在所有机器上设置此设置,这会影响该构建代理执行的每个构建 - 所以实际上最好只是将文件保存在如果可以,构建配置文件夹的根目录.

Note that if you had multiple build agents you would have to remember to set this setting on all of the machines, and it would affect every build performed by that build agent - so really it is best just to keep the files in the root of the build configuration folder if you can.

祝你好运,

马丁.

这篇关于TFSBuild.proj 和导入外部目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆