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

查看:69
本文介绍了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)中的任何文件上进行导入,因为在验证Import语句时,尚未从存储库中获取源.看起来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.

有没有办法做到这一点?

Is there a way to either:

  1. 告诉Team Build再下拉几个文件,以便那些Import语句正确评估吗?
  2. 以除Import之外的其他方式覆盖诸如AfterCompile之类的团队建设目标吗?
  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?

推荐答案

团队构建具有引导"阶段,在该阶段中,从版本控制中下载团队构建配置"文件夹(带有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.0 \ Common7 \ IDE中) \ PrivateAssemblies)

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.0\Common7\IDE\PrivateAssemblies)

<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天全站免登陆