ここで私の答えをチェックしてください: Modular TeamBuilds
コア機能を、すべてのビルドに含まれる共通の MSBuild ファイルにまとめておくことができます。さらに、これらのファイルはすべて、より広範なブランチ構造の一部であるため、追加の作業なしで既存の SDLC に直接参加します。したがって:
- ビルド スクリプトに危険な変更を加える場合は、他の危険な変更と同様に、"dev" または "private" ブランチで変更してください。
- 迅速な検証のためだけのビルド定義が必要な場合は、そのビルド定義によってインポートされた *.targets ファイルで、SkipLabel、SkipWorkItemCreation などのプロパティを False に設定します。
#2を少し拡張するために、「本番」ビルドと「テスト」ビルドの例を見てみましょう. 本番ビルドでのラベル付けなどの機能のみを有効にしたい。したがって、TFSBuild.proj から SkipLabel プロパティを削除し (そこに定義されている場合は TFSBuild.Common.targets も)、代わりに TFSBuild.Production.targets と TFSBuild.Test.targets に設定します (もちろん、2 つの異なる値を使用します)。
前の質問で述べたように、TFSBuild.proj は、ビルドの残りの部分がどのように動作するかを制御するマスター msbuild ファイルです。これが私のものです:
<?xml version="1.0" encoding="utf-8"?>
<!-- DO NOT EDIT the project element - the ToolsVersion specified here does not prevent the solutions
and projects in the SolutionToBuild item group from targeting other versions of the .NET framework.
-->
<Project DefaultTargets="DesktopBuild" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<!-- Import configuration for all MyCompany team builds -->
<Import Project="MyCompany.TeamBuild.Common.targets"/>
<!-- Import build-specific configurations -->
<Import Condition="'$(BuildDefinition)'=='Dev - quick'" Project="MyCompany.TeamBuild.Quick.targets" />
<Import Condition="'$(BuildDefinition)'=='Main - full'" Project="MyCompany.TeamBuild.Full.targets" />
<Import Condition="'$(BuildDefinition)'=='Main - quick'" Project="MyCompany.TeamBuild.Quick.targets" />
<Import Condition="'$(BuildDefinition)'=='Release - full'" Project="MyCompany.TeamBuild.Full.targets" />
<!-- This would be much cleaner as we add more branches, but msbuild doesn't support it :(
Imports are evaluated declaratively at parse-time, before any tasks execute
<Target Name="BeforeEndToEndIteration">
<RegexReplace Input="$(BuildDefinition)" Expression=".*\s-\s" Replacement="">
<Output TaskParameter="Output" PropertyName="BuildType" />
</RegexReplace>
</Target>
<Import Condition="$(BuildType)==full" Project="MyCompany.TeamBuild.Full.targets" />
<Import Condition="$(BuildType)==quick" Project="MyCompany.TeamBuild.Quick.targets" />
-->
</Project>
同様のことを行うことで、Dev ブランチからのすべてのビルドが「クイック」ビルド (ラベル付けなどがないことを意味します) であり、Release ブランチからのすべてのビルドが「完全な」ビルドであり、Main ブランチからのビルドがユーザーが Visual Studio / TSWA から起動するビルド定義によって異なります。私自身、継続的インテグレーションでセットアップされた「クイック」ビルドと、毎晩実行される「フル」ビルドがあります。