写在最前
首先得声明的是, 这篇文章不是来讲技术的而是讲实践的. 我理解这个题目的英文应该是<Best Practices On Team Foundation Build Automation Process> - 想要解决的问题是, 在微软提供的团队基础框架内, 如何更好的利用框架进行安排生成自动化流程的实践性问题. 想听技术讲解, 看细节分析的同学就不要苛求了, 因为技术还是那些技术. 但是, 实践虽然没有对错之分, 却有优劣之别. 本文的主旨, 就是将一些已经成熟的方案, 以及笔者在方面的经验, 汇集到一起讲述出来, 以备后来者之用. 考虑到平滑过渡的讲述需要, 我们会简单讲解基础概念和默认流程, 但是绝对不会面面俱到的讲解MSBuild和Team Foundation Build的所有细节.
另外需要说明的是, 本文所有的实践上的选择, 都是建立在现状的基础上. 这个现状指的是Team Foundation 2008平台和它的成熟应用. 其它不成熟或未发布的平台譬如Team Foundation 2010, 不在本文的讨论范围之内. 本文当然也不负责解释从TFS 2010成功发布, 直到进入软件生产领域真正需要的时间长度.
第三点需要说明的, 本文只假设所有的源代码都是基于.NET平台上的.如果您的代码项目中有大量标准C++项目, 那么在实践上选择可能会大不一样. 有可能这篇文章提到的一些实践方案, 反而是比较拙劣的.
第四点, 这篇文章假定您有了一定的MSBuild基础. 您应该了解目标(Target), 任务(Task)等MSBuild基本概念.
好了, 如果您看到这里还没有走掉, 那就让我们一起开始这段讨论吧.
团队基础之生成流程
生成(Build)重要吗?
对于软件开发者来说, 可能更关注的是编写代码, 是设计模式, 是将明确的需求转化为实实在在的代码. 编译生成? 不就是按一下F6(VS 默认快捷键)看看没有编译错误就可以了吗?
对于管理者来讲, 生成处于软件生产的核心地位. 最简单的原因是在生成之前, 是没有任何可以交付给用户的产品的. 如果我们把空间和时间上的范围扩大来看, 一个复杂软件系统的成功生成, 是各部分进行集成的最基本要求; 一个完整的生成流程, 也不仅仅是将代码转化为程序集这么简单, 它还可以包含自动化测试, 打包, 签名, 自动分发等过程. 这个流程的概念, 从代码文件一直延伸到可投递的产品.
所以生成很重要! 笔者曾一度认为完整的程序员应该了解整个系统的生成流程. 它既可以让程序员从整体上掌握各个部分对于整个系统的意义, 也可以明白以后再某个特定模块中做的修改对于整个系统和整个系统的生成流程的影响.
默认的团队项目生成流程
了解MSBuild的您肯定知道, MSBuild可执行脚本的内容, 无非就是一些Target标记和Task标记告诉MSBuild引擎去执行相应的一系列操作或某个特定操作. 这些Target被团队基础框架有机地组织起来组成"一整条"流程, 就是我们说的团队基础的生成流程. 在这篇文章中我们以"EndToEndIteration Build"来称谓团队基础的服务器端完整的生成过程, 这是一个单纯的过程定义(名字是具体的). EndToEndIteration Build这个过程中的某些相邻的逻辑上关系紧密的步骤, 我们把它拿出来赋予新的名字, 就成了它的子过程. 它的最大的也是最核心的子过程, 叫做"Team Build". 注意这也是个过程定义(同样名字是具体的). 生成代理(Build Agent)以MSBuild为生成引擎, 执行生成脚本文件, 完成完整的生成流程. Team Build在呈现上就是定义了一系列生成流程和生成任务的MSBuild脚本文件. 微软为Team Build定义了默认的Target脚本, 一般在本地硬盘的的这个位置: %ProgramFile%\MSBuild\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets. 下面就是这个默认脚本文件的全文. 在这个文件里微软定义了它认为合理的流程和各步骤职责.
- <?xml version="1.0" encoding="utf-8"?>
- <Project InitialTargets="CanonicalizePaths" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" >
- <!-- These tasks are used by the Team Build process defined in this file -->
- <UsingTask TaskName="Microsoft.TeamFoundation.Build.Tasks.GetBuildProperties"
- AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.ProcessComponents.dll"
- Condition=" '$(ProjectFileVersion)' != '2' "/>
- <UsingTask TaskName="Microsoft.TeamFoundation.Build.Tasks.SetBuildProperties"
- AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.ProcessComponents.dll"
- Condition=" '$(ProjectFileVersion)' != '2' "/>
- <UsingTask TaskName="Microsoft.TeamFoundation.Build.Tasks.BuildStep"
- AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.ProcessComponents.dll"
- Condition=" '$(ProjectFileVersion)' != '2' "/>
- <UsingTask TaskName="Microsoft.TeamFoundation.Build.Tasks.Get"
- AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.ProcessComponents.dll"
- Condition=" '$(ProjectFileVersion)' != '2' "/>
- <UsingTask TaskName="Microsoft.TeamFoundation.Build.Tasks.Label"
- AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.ProcessComponents.dll"
- Condition=" '$(ProjectFileVersion)' != '2' "/>
- <UsingTask TaskName="Microsoft.TeamFoundation.Build.Tasks.CreateNewWorkItem"
- AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.ProcessComponents.dll"
- Condition=" '$(ProjectFileVersion)' != '2' "/>
- <UsingTask TaskName="Microsoft.TeamFoundation.Build.Tasks.GenCheckinNotesUpdateWorkItems"
- AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.ProcessComponents.dll"
- Condition=" '$(ProjectFileVersion)' != '2' "/>
- <UsingTask TaskName="Microsoft.TeamFoundation.Build.UpdateBuildNumberDropLocation"
- AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.ProcessComponents.dll"
- Condition=" '$(ProjectFileVersion)' != '2' "/>
- <UsingTask TaskName="Microsoft.TeamFoundation.Build.Tasks.CreateWorkspaceTask"
- AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.ProcessComponents.dll"
- Condition=" '$(ProjectFileVersion)' != '2' "/>
- <UsingTask TaskName="Microsoft.TeamFoundation.Build.Tasks.DeleteWorkspaceTask"
- AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.ProcessComponents.dll"
- Condition=" '$(ProjectFileVersion)' != '2' "/>
- <UsingTask TaskName="Microsoft.TeamFoundation.Build.Tasks.WorkspaceItemConverterTask"
- AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.ProcessComponents.dll"
- Condition=" '$(ProjectFileVersion)' != '2' "/>
- <UsingTask TaskName="Microsoft.TeamFoundation.Build.Tasks.TestToolsTask"
- AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.ProcessComponents.dll"
- Condition=" '$(ProjectFileVersion)' != '2' "/>
- <UsingTask TaskName="Microsoft.TeamFoundation.TestImpact.BuildIntegration.BuildTasks.GetImpactedTests"
- AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.TestImpact.BuildIntegration.dll"
- Condition=" '$(ProjectFileVersion)' != '2' "/>
- <UsingTask TaskName="Microsoft.TeamFoundation.Build.Tasks.RevertWorkspaceTask"
- AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.ProcessComponents.dll"
- Condition=" '$(ProjectFileVersion)' != '2' "/>
- <!-- These tasks are used by the Team Build process defined in this file -->
- <UsingTask TaskName="Microsoft.TeamFoundation.Build.Tasks.GetBuildProperties"
- AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.Tasks.dll"
- Condition=" '$(ProjectFileVersion)' == '2' "/>
- <UsingTask TaskName="Microsoft.TeamFoundation.Build.Tasks.SetBuildProperties"
- AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.Tasks.dll"
- Condition=" '$(ProjectFileVersion)' == '2' "/>
- <UsingTask TaskName="Microsoft.TeamFoundation.Build.Tasks.BuildStep"
- AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.Tasks.dll"
- Condition=" '$(ProjectFileVersion)' == '2' "/>
- <UsingTask TaskName="Microsoft.TeamFoundation.Build.Tasks.Get"
- AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.Tasks.VersionControl.dll"
- Condition=" '$(ProjectFileVersion)' == '2' "/>
- <UsingTask TaskName="Microsoft.TeamFoundation.Build.Tasks.Label"
- AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.Tasks.VersionControl.dll"
- Condition=" '$(ProjectFileVersion)' == '2' "/>
- <UsingTask TaskName="Microsoft.TeamFoundation.Build.Tasks.CreateNewWorkItem"
- AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.Tasks.VersionControl.dll"
- Condition=" '$(ProjectFileVersion)' == '2' "/>
- <UsingTask TaskName="Microsoft.TeamFoundation.Build.Tasks.GenCheckinNotesUpdateWorkItems"
- AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.Tasks.VersionControl.dll"
- Condition=" '$(ProjectFileVersion)' == '2' "/>
- <UsingTask TaskName="Microsoft.TeamFoundation.Build.UpdateBuildNumberDropLocation"
- AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.Tasks.dll"
- Condition=" '$(ProjectFileVersion)' == '2' "/>
- <UsingTask TaskName="Microsoft.TeamFoundation.Build.Tasks.CreateWorkspaceTask"
- AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.Tasks.VersionControl.dll"
- Condition=" '$(ProjectFileVersion)' == '2' "/>
- <UsingTask TaskName="Microsoft.TeamFoundation.Build.Tasks.DeleteWorkspaceTask"
- AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.Tasks.VersionControl.dll"
- Condition=" '$(ProjectFileVersion)' == '2' "/>
- <UsingTask TaskName="Microsoft.TeamFoundation.Build.Tasks.WorkspaceItemConverterTask"
- AssemblyFile="$(TeamBuildRefPath)\Microsoft.TeamFoundation.Build.Tasks.VersionControl.dll"
- Condition=" '$(ProjectFileVersion)' == '2' "/>
- <UsingTask TaskName="TestToolsTask"
- AssemblyFile="$(MSTestRefPath)\Microsoft.VisualStudio.QualityTools.MSBuildTasks.dll"
- Condition=" '$(ProjectFileVersion)' == '2' "/>
- <!-- The Skip flags may be set to skip certain targets. -->
- <PropertyGroup>
- <!-- Version of Team Build -->
- <TeamBuildVersion>3.0</TeamBuildVersion>
- <!-- Path to Microsoft.VisualStudio.QualityTools.MSBuildTasks.dll. Overridable so that the 8.0 version can be used
- for test assemblies compiled against the 8.0 unit test framework. -->
- <MSTestRefPath Condition=" '$(MSTestRefPath)'=='' ">$(TeamBuildRefPath)</MSTestRefPath>
- <!-- Set this property to true to use the 8.0 TestToolsTask. -->
- <V8TestToolsTask Condition=" '$(V8TestToolsTask)'=='' ">false</V8TestToolsTask>
- <!-- Set this property to true to do an incremental get - this will override the CleanCompilationOutputOnly,
- SkipInitializeWorkspace, and ForceGet properties.
- -->
- <IncrementalGet Condition=" '$(IncrementalGet)'=='' " >false</IncrementalGet>
- <!-- Set this property to true to do an incremental build - this will override the SkipClean,
- SkipInitializeWorkspace, and ForceGet properties.
- -->
- <IncrementalBuild Condition=" '$(IncrementalBuild)'=='' ">false</IncrementalBuild>
- <!-- By default desktop build is true. The build agent overriddes this for end to end builds -->
- <IsDesktopBuild Condition=" '$(IsDesktopBuild)'=='' " >true</IsDesktopBuild>
- <!-- The Project File Version is defaulted here to 2. This ensures that older project files will find the correct
- versions of the Task dlls referenced above. For versions of Team Build above 2, this property will be
- overriden on the command line to match that version. -->
- <ProjectFileVersion Condition=" '$(ProjectFileVersion)'=='' and '$(IsDesktopBuild)'!='true' ">2</ProjectFileVersion>
- <!-- For desktop builds, the Project File Version is defaulted to 3 so that Dev10 can support desktop builds without requiring
- an override to be passed in. -->
- <ProjectFileVersion Condition=" '$(ProjectFileVersion)'=='' and '$(IsDesktopBuild)'=='true' ">3</ProjectFileVersion>
- <!-- If BuildProjectFolderPath is not specified (typically in a Desktop build), assume local paths
- and set to MSBuildProjectDirectory
- -->
- <BuildProjectFolderPath Condition=" '$(BuildProjectFolderPath)'=='' ">$(MSBuildProjectDirectory)</BuildProjectFolderPath>
- <!-- Set this property to true to skip the CoreClean target. -->
- <SkipClean Condition=" '$(SkipClean)'=='' " >false</SkipClean>
- <!-- Set this property to true to clean without deleting sources.
- Note that direct use of this property is discouraged - the IncrementalGet and IncrementalBuild properties
- should be used instead.
- -->
- <CleanCompilationOutputOnly Condition=" '$(CleanCompilationOutputOnly)'=='' and '$(IsDesktopBuild)'!='true' ">false</CleanCompilationOutputOnly>
- <!-- For a Desktop build, cleaning without deleting sources is the default behavior -->
- <CleanCompilationOutputOnly Condition=" '$(CleanCompilationOutputOnly)'=='' and '$(IsDesktopBuild)'=='true' ">true</CleanCompilationOutputOnly>
- <!-- Set this property to true to skip the CoreInitializeWorkspace target.
- Note that direct use of this property is discouraged - the IncrementalGet and IncrementalBuild properties
- should be used instead.
- -->
- <SkipInitializeWorkspace Condition=" '$(SkipInitializeWorkspace)'=='' " >false</SkipInitializeWorkspace>
- <!-- Set this property to true to skip the CoreGet target.
- Note that direct use of this property is discouraged - the IncrementalGet and IncrementalBuild properties
- should be used instead.
- -->
- <SkipGet Condition=" '$(SkipGet)'=='' " >false</SkipGet>
- <!-- Set this property to true to skip the CoreLabel target. -->
- <SkipLabel Condition=" '$(SkipLabel)'=='' " >false</SkipLabel>
- <!-- Set this property to true to skip the PostBuild target. -->
- <SkipPostBuild Condition=" '$(SkipPostBuild)'=='' " >false</SkipPostBuild>
- <!-- Set this property to skip the CoreGetChangesetsAndUpdateWorkItems target, which calls the GenCheckinNotesUpdateWorkItems task. -->
- <SkipGetChangesetsAndUpdateWorkItems Condition=" '$(SkipGetChangesetsAndUpdateWorkItems)'=='' ">false</SkipGetChangesetsAndUpdateWorkItems>
- <!-- Set this property to true to skip the CoreDropBuild target. -->
- <SkipDropBuild Condition=" '$(SkipDropBuild)'=='' " >false</SkipDropBuild>
- <!-- Set this property to true to skip the CoreCreateWorkItem target. -->
- <SkipWorkItemCreation Condition=" '$(SkipWorkItemCreation)'=='' " >false</SkipWorkItemCreation>
- <!-- Set this property to false to skip the publishing of test results (tests will still be run). -->
- <PublishTestResults Condition=" '$(PublishTestResults)' == '' ">true</PublishTestResults>
- </PropertyGroup>
- <!-- Additional properties that may be set to customize the build process -->
- <PropertyGroup>
- <!-- Set this property to true to enable building configurations in parallel. -->
- <BuildConfigurationsInParallel Condition=" '$(BuildConfigurationsInParallel)'=='' ">true</BuildConfigurationsInParallel>
- <!-- Set this property to true to enable building solutions in parallel. -->
- <BuildSolutionsInParallel Condition=" '$(BuildSolutionsInParallel)'=='' ">true</BuildSolutionsInParallel>
- <!-- Set this property to false to generate an error when an invalid configuration is encountered. -->
- <SkipInvalidConfigurations Condition=" '$(SkipInvalidConfigurations)'=='' ">true</SkipInvalidConfigurations>
- <!-- Set this property to true to stop Cleaning, Compiling, and/or Testing on the first failure encountered -->
- <StopOnFirstFailure Condition=" '$(StopOnFirstFailure)'=='' ">false</StopOnFirstFailure>
- <!-- Set this property to true to stop on a test failure or false to continue on a test failure -->
- <StopOnTestFailure Condition=" '$(StopOnTestFailure)'=='' ">false</StopOnTestFailure>
- <!-- Set this property to true to mark builds as Failed when TestStatus is Failed -->
- <TreatTestFailureAsBuildFailure Condition=" '$(TreatTestFailureAsBuildFailure)'=='' ">false</TreatTestFailureAsBuildFailure>
- <!-- The targets specified in this property will cause ProjectStartedEvents to not be logged. The default values are the P2P reference targets
- from MSBuild 3.5 - GetTargetPath, GetNativeManifest, and GetCopyToOutputDirectoryItems.
- -->
- <TargetsNotLogged Condition=" '$(TargetsNotLogged)' == '' ">GetTargetPath;GetNativeManifest;GetCopyToOutputDirectoryItems</TargetsNotLogged>
- <!-- The default solution root for desktop builds -->
- <SolutionRoot Condition=" '$(SolutionRoot)'=='' and '$(IsDesktopBuild)'=='true' " >$(MSBuildProjectDirectory)\..\..</SolutionRoot>
- <!-- The default sources subdirectory -->
- <SourcesSubdirectory Condition=" '$(SourcesSubdirectory)'=='' ">Sources</SourcesSubdirectory>
- <!-- The default solution root for end to end builds -->
- <SolutionRoot Condition=" '$(SolutionRoot)'=='' and '$(IsDesktopBuild)'!='true' " >$(MSBuildProjectDirectory)\..\$(SourcesSubdirectory)</SolutionRoot>
- <!-- The default binaries subdirectory -->
- <BinariesSubdirectory Condition=" '$(BinariesSubdirectory)'=='' ">Binaries</BinariesSubdirectory>
- <!-- The default binaries root -->
- <BinariesRoot Condition=" '$(BinariesRoot)'=='' " >$(SolutionRoot)\..\$(BinariesSubdirectory)</BinariesRoot>
- <!-- The default test results subdirectory-->
- <TestResultsSubdirectory Condition=" '$(TestResultsSubdirectory)'=='' ">TestResults</TestResultsSubdirectory>
- <!-- The default test results root -->
- <TestResultsRoot Condition=" '$(TestResultsRoot)'=='' " >$(SolutionRoot)\..\$(TestResultsSubdirectory)</TestResultsRoot>
- <!--
- The name of the workspace that will be used for getting sources.
- Note: Workspace name can be up to 64 characters long - after that it will be truncated.
- -->
- <WorkspaceName Condition=" '$(WorkspaceName)'=='' " >$(COMPUTERNAME)_$(BuildDefinitionId)_$(BuildAgentId)</WorkspaceName>
- <!-- The comment used for workspace creation -->
- <CreateWorkspaceTaskComment Condition=" '$(CreateWorkspaceTaskComment)'=='' ">Workspace created by Team Build</CreateWorkspaceTaskComment>
- <!-- Set this to false to do an incremental get.
- Note that direct use of this property is discouraged - the IncrementalGet and IncrementalBuild properties
- should be used instead.
- -->
- <ForceGet Condition=" '$(ForceGet)'=='' ">true</ForceGet>
- <!-- Set this value to true to enable overwriting of writable files without a force get -->
- <GetOverwrite Condition=" '$(GetOverwrite)'=='' ">false</GetOverwrite>
- <!-- Set this to false to do only a top-level get -->
- <RecursiveGet Condition=" '$(RecursiveGet)'=='' ">true</RecursiveGet>
- <!-- The VersionSpec to be used by the Get task -->
- <GetVersion Condition=" '$(GetVersion)'=='' ">$(SourceGetVersion)</GetVersion>
- <!-- The FileSpec to be used by the Get task. When empty, all top-level folders in the workspace are used. -->
- <GetFileSpec Condition=" '$(GetFileSpec)'=='' "></GetFileSpec>
- <!-- Set this to true to populate the Gets, Replaces, and Deletes item group outputs of the Get task -->
- <GetPopulateOutput Condition=" '$(GetPopulateOutput)'=='' ">false</GetPopulateOutput>
- <!-- Set this to false to fail the build if unmapped files exist in a shelveset -->
- <GetAllowUnmapped Condition=" '$(GetAllowUnmapped)'=='' ">true</GetAllowUnmapped>
- <!-- Set this to false to fail if there are any change conflicts (even if they can be auto merged) -->
- <GetAutoMerge Condition=" '$(GetAutoMerge)'=='' ">true</GetAutoMerge>
- <!-- Set this to false to remove the ***NO_CI*** which is appended to gated check-ins -->
- <GetNoCIOption Condition=" '$(GetNoCIOption)'=='' ">true</GetNoCIOption>
- <!-- Set this to false to do only a top-level label -->
- <LabelRecursive Condition=" '$(LabelRecursive)'=='' ">true</LabelRecursive>
- <!-- Set this to Merge or Replace to control the treatment of unchanged items -->
- <LabelChild Condition=" '$(LabelChild)'=='' ">Replace</LabelChild>
- <!-- The comment used by the Label task -->
- <LabelComment Condition=" '$(LabelComment)'=='' ">Label created by Team Build</LabelComment>
- <!-- The label name used by the Label task. By default the label name is set to $(BuildNumber) in the
- InitializeEndToEndIteration target.
- -->
- <LabelName Condition=" '$(LabelName)'=='' "></LabelName>
- <!-- The FileSpec to be used by the Label task -->
- <LabelFiles Condition=" '$(LabelFiles)'=='' ">$/</LabelFiles>
- <!-- The scope to be used by the Label task -->
- <LabelScope Condition=" '$(LabelScope)'=='' ">$/$(TeamProject)</LabelScope>
- <!-- The AdditionalLibPaths property of the VCBuild task used to compile VC++ projects -->
- <VCBuildAdditionalLibPaths Condition=" '$(VCBuildAdditionalLibPaths)'=='' "></VCBuildAdditionalLibPaths>
- <!-- The AdditionalOptions property of the VCBuild task used to compile VC++ projects -->
- <VCBuildAdditionalOptions Condition=" '$(VCBuildAdditionalOptions)'=='' "></VCBuildAdditionalOptions>
- <!-- The ToolPath property of the VCBuild task used to compile VC++ projects -->
- <VCBuildToolPath Condition=" '$(VCBuildToolPath)'=='' "></VCBuildToolPath>
- <!-- The UseEnvironment property of the VCBuild task used to compile VC++ projects -->
- <VCBuildUseEnvironment Condition=" '$(VCBuildUseEnvironment)'=='' "></VCBuildUseEnvironment>
- <!-- The beginning of the vsprops file used to override VCBuild properties. -->
- <VCOverridesOpen Condition=" '$(VCOverridesOpen)'=='' ">%3C?xml version=%221.0%22?%3E%0D%0A%3CVisualStudioPropertySheet ProjectType=%22Visual C++%22 Version=%228.00%22 Name=%22Team Build Overrides%22</VCOverridesOpen>
- <!-- The end of the vsprops file used to override VCBuild properties. -->
- <VCOverridesClose Condition=" '$(VCOverridesClose)'=='' ">%3C/VisualStudioPropertySheet%3E</VCOverridesClose>
- <!-- Set this to true to update associated work items even on a build break -->
- <UpdateAssociatedWorkItemsOnBuildBreak Condition=" '$(UpdateAssociatedWorkItemsOnBuildBreak)'=='' ">false</UpdateAssociatedWorkItemsOnBuildBreak>
- <!-- Set this to true to allow OutDir customization -->
- <CustomizableOutDir Condition=" '$(CustomizableOutDir)'=='' ">false</CustomizableOutDir>
- <!-- Set this to true to allow PublishDir customization -->
- <CustomizablePublishDir Condition=" '$(CustomizablePublishDir)'=='' ">false</CustomizablePublishDir>
- <!-- Set OutDir so that it is always available within TfsBuild.proj for backwards compatibility -->
- <OutDir Condition=" '$(OutDir)'=='' and '$(TeamBuildOutDir)'!='' ">$(TeamBuildOutDir)</OutDir>
- <!-- Set PublishDir so that it is always available within TfsBuild.proj for backwards compatibility -->
- <PublishDir Condition=" '$(PublishDir)'=='' and '$(TeamBuildPublishDir)'!='' ">$(TeamBuildPublishDir)</PublishDir>
- <!-- Set this property to false to disable test impact analysis. -->
- <PerformTestImpactAnalysis Condition="'$(PerformTestImpactAnalysis)' == ''">true</PerformTestImpactAnalysis>
- </PropertyGroup>
- <ItemGroup>
- <!-- Create the various paths as items so we can use %(FullPath) on them. -->
- <SolutionRootItem Include="$(SolutionRoot)" />
- <BinariesRootItem Include="$(BinariesRoot)" />
- <TestResultsRootItem Include="$(TestResultsRoot)" />
- </ItemGroup>
- <PropertyGroup>
- <!-- Canonicalize the various paths. -->
- <_SolutionRoot>@(SolutionRootItem->'%(FullPath)')</_SolutionRoot>
- <_BinariesRoot>@(BinariesRootItem->'%(FullPath)')</_BinariesRoot>
- <_TestResultsRoot>@(TestResultsRootItem->'%(FullPath)')</_TestResultsRoot>
- </PropertyGroup>
- <!-- Properties needed to locate required assemblies during the build process -->
- <PropertyGroup Condition=" '$(IsDesktopBuild)'=='true' ">
- <!-- The location of Team Build task assemblies on the build machine -->
- <DevEnvDir Condition=" '$(DevEnvDir)'=='' and '$(NetSamplePath)'!='' " >$(NetSamplePath)\..\..\Common7\IDE</DevEnvDir>
- <TeamBuildRefPath Condition=" '$(TeamBuildRefPath)'=='' " >$(DevEnvDir)\PrivateAssemblies</TeamBuildRefPath>
- <!-- Path to Microsoft.VisualStudio.QualityTools.MSBuildTasks.dll. Overridable so that the 8.0 version can be used
- for test assemblies compiled against the 8.0 unit test framework. -->
- <MSTestRefPath Condition=" '$(MSTestRefPath)'=='' ">$(TeamBuildRefPath)</MSTestRefPath>
- <!-- The location of Code Analysis assemblies on the build machine -->
- <VSINSTALLDIR Condition=" '$(VSINSTALLDIR)'=='' and '$(NetSamplePath)'!='' " >$(NetSamplePath)\..\..</VSINSTALLDIR>
- <FxCopDir Condition=" '$(FxCopDir)'=='' " >$(VSINSTALLDIR)\Team Tools\Static Analysis Tools\FxCop</FxCopDir>
- </PropertyGroup>
- <Target Name="CanonicalizePaths">
- <!-- Force evaluation of canonicalized paths. -->
- <PropertyGroup>
- <SolutionRoot>$(_SolutionRoot)</SolutionRoot>
- <BinariesRoot>$(_BinariesRoot)</BinariesRoot>
- <TestResultsRoot>$(_TestResultsRoot)</TestResultsRoot>
- </PropertyGroup>
- </Target>
- <Target Name="InitializeBuildProperties">
- <GetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
- BuildUri="$(BuildUri)"
- Condition=" '$(IsDesktopBuild)' != 'true' ">
- <!-- Outputs are the initial values for the various properties of the build. -->
- <Output TaskParameter="BuildDefinitionName" PropertyName="BuildDefinitionName" />
- <Output TaskParameter="BuildDefinitionUri" PropertyName="BuildDefinitionUri" />
- <Output TaskParameter="BuildNumber" PropertyName="BuildNumber" />
- <Output TaskParameter="CompilationStatus" PropertyName="CompilationStatus" />
- <Output TaskParameter="CompilationSuccess" PropertyName="CompilationSuccess" />
- <Output TaskParameter="ConfigurationFolderUri" PropertyName="ConfigurationFolderUri" />
- <Output TaskParameter="DropLocation" PropertyName="DropLocation" />
- <Output TaskParameter="LabelName" PropertyName="FullLabelName" />
- <Output TaskParameter="LastChangedBy" PropertyName="LastChangedBy" />
- <Output TaskParameter="LastChangedOn" PropertyName="LastChangedOn" />
- <Output TaskParameter="LogLocation" PropertyName="LogLocation" />
- <Output TaskParameter="Port" PropertyName="Port" />
- <Output TaskParameter="Quality" PropertyName="Quality" />
- <Output TaskParameter="Reason" PropertyName="Reason" />
- <Output TaskParameter="RequestedBy" PropertyName="RequestedBy" />
- <Output TaskParameter="RequestedFor" PropertyName="RequestedFor" />
- <Output TaskParameter="SourceGetVersion" PropertyName="SourceGetVersion" />
- <Output TaskParameter="StartTime" PropertyName="StartTime" />
- <Output TaskParameter="Status" PropertyName="Status" />
- <Output TaskParameter="TeamProject" PropertyName="TeamProject" />
- <Output TaskParameter="TestStatus" PropertyName="TestStatus" />
- <Output TaskParameter="TestSuccess" PropertyName="TestSuccess" />
- <!-- Get these properties for backwards compatibility only if they are not already set. -->
- <Output TaskParameter="BuildAgentName" PropertyName="BuildAgentName" Condition=" '$(BuildAgentName)' == '' " />
- <Output TaskParameter="BuildAgentUri" PropertyName="BuildAgentUri" Condition=" '$(BuildAgentUri)' == '' " />
- <Output TaskParameter="BuildDirectory" PropertyName="BuildDirectory" Condition=" '$(BuildDirectory)' == '' " />
- <Output TaskParameter="MachineName" PropertyName="MachineName" Condition=" '$(MachineName)' == '' " />
- <Output TaskParameter="MaxProcesses" PropertyName="MaxProcesses" Condition=" '$(MaxProcesses)' == '' " />
- </GetBuildProperties>
- </Target>
- <!-- Check settings for EndToEndIteration -->
- <Target Name="CheckSettingsForEndToEndIteration"
- Condition=" '$(IsDesktopBuild)'!='true' ">
- <Error Condition=" '$(BuildDefinition)'=='' " Text="The BuildDefinition property is not set." />
- <Error Condition=" '$(BuildDefinitionId)'=='' " Text="The BuildDefinitionId property is not set." />
- <Error Condition=" '$(BuildUri)'=='' " Text="The BuildUri property is not set." />
- <Error Condition=" '$(COMPUTERNAME)'=='' " Text="The COMPUTERNAME property is not set." />
- <Error Condition=" '$(TeamFoundationServerUrl)'=='' " Text="The TeamFoundationServerUrl property is not set." />
- <Error Condition=" '$(TeamProject)'=='' " Text="The TeamProject property is not set." />
- <Message Text="BuildDefinition=$(BuildDefinition)" Importance="Low" />
- <Message Text="BuildDefinitionId=$(BuildDefinitionId)" Importance="Low" />
- <Message Text="BuildUri=$(BuildUri)" Importance="Low" />
- <Message Text="ComputerName=$(COMPUTERNAME)" Importance="Low" />
- <Message Text="TeamFoundationServerUrl=$(TeamFoundationServerUrl)" Importance="Low" />
- <Message Text="TeamProject=$(TeamProject)" Importance="Low" />
- </Target>
- <!-- Entry point for desktop build -->
- <PropertyGroup>
- <DesktopBuildDependsOn>
- Compile;
- Test;
- GenerateDocumentation;
- PackageBinaries;
- </DesktopBuildDependsOn>
- </PropertyGroup>
- <Target Name="DesktopBuild"
- Condition=" '$(IsDesktopBuild)'=='true' "
- DependsOnTargets="$(DesktopBuildDependsOn)" />
- <!-- Entry point for desktop rebuild -->
- <PropertyGroup>
- <DesktopRebuildDependsOn>
- Clean;
- DesktopBuild;
- </DesktopRebuildDependsOn>
- </PropertyGroup>
- <Target Name="DesktopRebuild"
- Condition=" '$(IsDesktopBuild)'=='true' "
- DependsOnTargets="$(DesktopRebuildDependsOn)" />
- <!-- Override this target to execute custom tasks before EndToEndIteration -->
- <Target Name="BeforeEndToEndIteration" />
- <!--
- Override this target to execute a task for customizing the build number and/or drop location.
- Make sure that the task outputs properties with the names 'BuildNumber' and/or 'DropLocation'.
- -->
- <Target Name="BuildNumberOverrideTarget" />
- <PropertyGroup>
- <EndToEndIterationDependsOn>
- CheckSettingsForEndToEndIteration;
- InitializeBuildProperties;
- BeforeEndToEndIteration;
- BuildNumberOverrideTarget;
- InitializeEndToEndIteration;
- InitializeWorkspace;
- TeamBuild;
- DropBuild;
- RevertWorkspace;
- AfterEndToEndIteration;
- </EndToEndIterationDependsOn>
- </PropertyGroup>
- <!-- Entry point: this target is invoked on the build machine by the build agent -->
- <Target Name="EndToEndIteration"
- Condition=" '$(IsDesktopBuild)'!='true' "
- DependsOnTargets="$(EndToEndIterationDependsOn)" />
- <!-- Override this target to execute custom tasks after EndToEndIteration -->
- <Target Name="AfterEndToEndIteration" />
- <!-- Initialize the build for EndToEndIteration -->
- <Target Name="InitializeEndToEndIteration" >
- <!-- IncrementalGet == true implies CleanCompilationOutputOnly = true, SkipInitializeWorkspace = true, and ForceGet = false -->
- <PropertyGroup Condition=" '$(IncrementalGet)'=='true' ">
- <CleanCompilationOutputOnly>true</CleanCompilationOutputOnly>
- <SkipInitializeWorkspace>true</SkipInitializeWorkspace>
- <ForceGet>false</ForceGet>
- </PropertyGroup>
- <!-- IncrementalBuild == true implies SkipClean = true, SkipInitializeWorkspace = true, and ForceGet = false -->
- <PropertyGroup Condition=" '$(IncrementalBuild)'=='true' ">
- <SkipClean>true</SkipClean>
- <SkipInitializeWorkspace>true</SkipInitializeWorkspace>
- <ForceGet>false</ForceGet>
- </PropertyGroup>
- <!-- Update the build number and drop location in the database. This task will also create the drop directory
- and grant the service account full rights on it.
- -->
- <UpdateBuildNumberDropLocation
- TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
- BuildUri="$(BuildUri)"
- BuildNumber="$(BuildNumber)"
- DropLocation="$(DropLocation)\$(BuildNumber)" />
- <PropertyGroup>
- <LabelName Condition=" '$(LabelName)'=='' ">$(BuildNumber)</LabelName>
- </PropertyGroup>
- </Target>
- <!-- CleanAll - executes the Clean target after the Get target, and deletes the entire
- sources directory. -->
- <PropertyGroup>
- <CleanAllDependsOn>
- BeforeClean;
- CoreCleanAll;
- AfterClean;
- </CleanAllDependsOn>
- </PropertyGroup>
- <Target Name="CleanAll"
- Condition=" '$(CleanCompilationOutputOnly)'!='true' "
- DependsOnTargets="$(CleanAllDependsOn)" />
- <!-- CleanComilationOutput - executes the Clean target before the Get target, and executes
- the Clean target of each item in the SolutionToBuild item group. -->
- <PropertyGroup>
- <CleanCompilationOutputDependsOn>
- BeforeClean;
- CallClean;
- AfterClean;
- </CleanCompilationOutputDependsOn>
- </PropertyGroup>
- <Target Name="CleanCompilationOutput"
- Condition=" '$(CleanCompilationOutputOnly)'=='true' "
- DependsOnTargets="$(CleanCompilationOutputDependsOn)" />
- <!-- Override this target to execute custom tasks before clean -->
- <Target Name="BeforeClean" />
- <!-- Backwards compatibility. Calls appropriate Core target based on the value of
- $(CleanCompilationOutputOnly). -->
- <PropertyGroup>
- <CleanDependsOn>
- BeforeClean;
- CoreClean;
- AfterClean;
- </CleanDependsOn>
- </PropertyGroup>
- <!-- Batch target for cleanup -->
- <Target Name="Clean"
- DependsOnTargets="$(CleanDependsOn)" />
- <!-- Override this target to execute custom tasks after clean -->
- <Target Name="AfterClean" />
- <PropertyGroup>
- <CoreCleanDependsOn>
- </CoreCleanDependsOn>
- </PropertyGroup>
- <Target Name="CoreClean"
- DependsOnTargets="$(CoreCleanDependsOn)">
- <CallTarget Condition=" '$(CleanCompilationOutputOnly)'!='true' "
- Targets="CoreCleanAll" />
- <CallTarget Condition=" '$(CleanCompilationOutputOnly)'=='true' "
- Targets="CallClean" />
- </Target>
- <PropertyGroup>
- <CoreCleanAllDependsOn/>
- </PropertyGroup>
- <!-- Old style Clean - just remove directories -->
- <Target Name="CoreCleanAll"
- Condition=" '$(SkipClean)'!='true' "
- DependsOnTargets="$(CoreCleanAllDependsOn)">
- <RemoveDir Condition="Exists('$(SolutionRoot)')"
- Directories="$(SolutionRoot)" />
- <RemoveDir Condition="Exists('$(BinariesRoot)')"
- Directories="$(BinariesRoot)" />
- <RemoveDir Condition="Exists('$(TestResultsRoot)')"
- Directories="$(TestResultsRoot)" />
- </Target>
- <!-- Call CoreCleanCompilationOutput via an MSBuild Task to ensure that ComputeConfigurationList gets executed
- if any properties have changed. -->
- <Target Name="CallClean"
- Condition=" '$(SkipClean)'!='true' ">
- <!-- Pass in all properties that users might want during the course of the clean targets. -->
- <MSBuild Projects="$(MSBuildProjectFile)"
- Properties="BuildAgentName=$(BuildAgentName);BuildAgentUri=$(BuildAgentUri);BuildDefinitionName=$(BuildDefinitionName);BuildDefinitionUri=$(BuildDefinitionUri);
- BuildDirectory=$(BuildDirectory);BuildNumber=$(BuildNumber);CompilationStatus=$(CompilationStatus);CompilationSuccess=$(CompilationSuccess);
- ConfigurationFolderUri=$(ConfigurationFolderUri);DropLocation=$(DropLocation);
- FullLabelName=$(FullLabelName);LastChangedBy=$(LastChangedBy);LastChangedOn=$(LastChangedOn);LogLocation=$(LogLocation);
- MachineName=$(MachineName);MaxProcesses=$(MaxProcesses);Port=$(Port);Quality=$(Quality);Reason=$(Reason);RequestedBy=$(RequestedBy);RequestedFor=$(RequestedFor);
- SourceGetVersion=$(SourceGetVersion);StartTime=$(StartTime);Status=$(Status);TeamProject=$(TeamProject);TestStatus=$(TestStatus);
- TestSuccess=$(TestSuccess);WorkspaceName=$(WorkspaceName);WorkspaceOwner=$(WorkspaceOwner);
- SolutionRoot=$(SolutionRoot);BinariesRoot=$(BinariesRoot);TestResultsRoot=$(TestResultsRoot);
- $(CustomPropertiesForClean)"
- Targets="CoreCleanCompilationOutput">
- <Output TaskParameter="TargetOutputs" ItemName="CleanOutputs" />
- </MSBuild>
- </Target>
- <PropertyGroup>
- <CoreCleanCompilationOutputDependsOn>
- ComputeConfigurationList;
- </CoreCleanCompilationOutputDependsOn>
- </PropertyGroup>
- <!-- New style Clean - call MSBuild /t:Clean for each solution, then remove the Binaries and TestResults directories -->
- <Target Name="CoreCleanCompilationOutput"
- DependsOnTargets="$(CoreCleanCompilationOutputDependsOn)"
- Outputs="@(CleanOutputs)">
- <MSBuild BuildInParallel="$(BuildConfigurationsInParallel)"
- Projects="@(ConfigurationList)"
- Targets="CleanConfiguration"
- StopOnFirstFailure="$(StopOnFirstFailure)">
- <Output TaskParameter="TargetOutputs" ItemName="CleanOutputs" />
- </MSBuild>
- <RemoveDir
- Condition="Exists('$(BinariesRoot)')"
- Directories="$(BinariesRoot)" />
- <RemoveDir
- Condition="Exists('$(TestResultsRoot)')"
- Directories="$(TestResultsRoot)" />
- </Target>
- <Target Name="BeforeCleanConfiguration" />
- <PropertyGroup>
- <CleanConfigurationDependsOn>
- BeforeCleanConfiguration;
- CoreCleanConfiguration;
- AfterCleanConfiguration;
- </CleanConfigurationDependsOn>
- </PropertyGroup>
- <Target Name="CleanConfiguration"
- DependsOnTargets="$(CleanConfigurationDependsOn)"
- Outputs="@(CleanOutputs)" />
- <Target Name="AfterCleanConfiguration" />
- <PropertyGroup>
- <CoreCleanConfigurationDependsOn>
- ComputeSolutionList;
- </CoreCleanConfigurationDependsOn>
- </PropertyGroup>
- <!-- Clean for Platform / Configuration combination -->
- <Target Name="CoreCleanConfiguration"
- DependsOnTargets="$(CoreCleanConfigurationDependsOn)">
- <MSBuild BuildInParallel="$(BuildSolutionsInParallel)"
- Projects="@(SolutionList)"
- Targets="CleanSolution"
- StopOnFirstFailure="$(StopOnFirstFailure)">
- <Output TaskParameter="TargetOutputs" ItemName="CleanOutputs" />
- </MSBuild>
- <!-- Add Platform and Configuration metadata to CleanOutputs. -->
- <ItemGroup>
- <CleanOutputs>
- <Platform>$(Platform)</Platform>
- <Configuration>$(Configuration)</Configuration>
- </CleanOutputs>
- </ItemGroup>
- </Target>
- <!-- Override this target to execute custom tasks before cleaning an individual solution -->
- <Target Name="BeforeCleanSolution" />
- <!-- Clean for individual Solution -->
- <PropertyGroup>
- <CleanSolutionDependsOn>
- BeforeCleanSolution;
- CoreCleanSolution;
- AfterCleanSolution;
- </CleanSolutionDependsOn>
- </PropertyGroup>
- <Target Name="CleanSolution"
- DependsOnTargets="$(CleanSolutionDependsOn)"
- Outputs="@(CleanOutputs)" />
- <!-- Override this target to execute custom tasks after cleaning an individual solution -->
- <Target Name="AfterCleanSolution" />
- <Target Name="CoreCleanSolution"
- Condition=" Exists($(Solution)) ">
- <PropertyGroup>
- <VsPropsFile Condition=" '$(Platform)' != 'Any CPU' ">$(Solution).$(Platform).$(Configuration).vsprops</VsPropsFile>
- <VsPropsFile Condition=" '$(Platform)' == 'Any CPU' ">$(Solution).$(Configuration).vsprops</VsPropsFile>
- <OutDirOption Condition=" '$(CustomizableOutDir)' != 'true' ">OutDir=$(TeamBuildOutDir)</OutDirOption>
- <PublishDirOption Condition=" '$(CustomizablePublishDir)' != 'true' ">PublishDir=$(TeamBuildPublishDir)</PublishDirOption>
- </PropertyGroup>
- <!-- Generate the VCOverride file for C++ projects -->
- <WriteLinesToFile Condition=" '$(CustomizableOutDir)' != 'true' "
- File="$(VsPropsFile)"
- Lines="$(VCOverridesOpen) OutputDirectory=%22$(OutDir)%22%3E%0D%0A$(AdditionalVCOverrides)$(VCOverridesClose)"
- Overwrite="true" />
- <WriteLinesToFile Condition=" '$(CustomizableOutDir)' == 'true' "
- File="$(VsPropsFile)"
- Lines="$(VCOverridesOpen) %3E%0D%0A$(AdditionalVCOverrides)$(VCOverridesClose)"
- Overwrite="true" />
- <!-- Call MSBuild /t:Clean for each solution -->
- <MSBuild BuildInParallel="$(BuildSolutionsInParallel)"
- Projects="$(Solution)"
- Properties="Configuration=$(Configuration);Platform=$(Platform);$(OutDirOption);$(PublishDirOption);SkipInvalidConfigurations=$(SkipInvalidConfigurations);
- VCBuildOverride=$(VsPropsFile);VCBuildAdditionalLibPaths=$(VCBuildAdditionalLibPaths);VCBuildAdditionalOptions=$(VCBuildAdditionalOptions);VCBuildToolPath=$(VCBuildToolPath);VCBuildUseEnvironment=$(VCBuildUseEnvironment);
- $(CustomPropertiesForClean)"
- Targets="Clean"
- StopOnFirstFailure="$(StopOnFirstFailure)">
- <Output TaskParameter="TargetOutputs" ItemName="CleanOutputs" />
- </MSBuild>
- </Target>
- <PropertyGroup>
- <TeamBuildDependsOn>
- CleanAll;
- InitializeBuild;
- PreBuild;
- CleanCompilationOutput;
- Compile;
- PostBuild;
- GetImpactedTests;
- Test;
- GenerateDocumentation;
- PackageBinaries;
- </TeamBuildDependsOn>
- </PropertyGroup>
- <!-- Batch target for non desktop build -->
- <Target Name="TeamBuild"
- Condition=" '$(IsDesktopBuild)'!='true' "
- DependsOnTargets="$(TeamBuildDependsOn)" />
- <Target Name="InitializeBuild"
- Condition=" '$(IsDesktopBuild)'!='true' " >
- <!-- Create a folder for the source files -->
- <MakeDir
- Directories="$(SolutionRoot)"
- Condition="!Exists('$(SolutionRoot)')" />
- </Target>
- <PropertyGroup>
- <PreBuildDependsOn>
- Get;
- Label;
- </PreBuildDependsOn>
- </PropertyGroup>
- <Target Name="PreBuild"
- Condition=" '$(IsDesktopBuild)'!='true' "
- DependsOnTargets="$(PreBuildDependsOn)" />
- <!-- Override this target to execute custom tasks before workspace initialization -->
- <Target Name="BeforeInitializeWorkspace" />
- <PropertyGroup>
- <InitializeWorkspaceDependsOn>
- BeforeInitializeWorkspace;
- CoreInitializeWorkspace;
- AfterInitializeWorkspace;
- </InitializeWorkspaceDependsOn>
- </PropertyGroup>
- <!-- Batch target for initializing the workspace -->
- <Target Name="InitializeWorkspace"
- DependsOnTargets="$(InitializeWorkspaceDependsOn)"/>
- <!-- Override this target to execute custom tasks after workspace initialization -->
- <Target Name="AfterInitializeWorkspace" />
- <PropertyGroup>
- <CoreInitializeWorkspaceDependsOn />
- </PropertyGroup>
- <Target Name="CoreInitializeWorkspace"
- Condition=" '$(IsDesktopBuild)'!='true' "
- DependsOnTargets="$(CoreInitializeWorkspaceDependsOn)" >
- <!-- Delete the workspace left by the previous build -->
- <DeleteWorkspaceTask
- Condition=" '$(SkipInitializeWorkspace)'!='true' and '$(CleanCompilationOutputOnly)' != 'true' and '$(SkipClean)' != 'true' "
- TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
- BuildUri="$(BuildUri)"
- Name="$(WorkspaceName)"
- DeleteLocalItems="true" />
- <DeleteWorkspaceTask
- Condition=" '$(SkipInitializeWorkspace)'!='true' and ('$(CleanCompilationOutputOnly)' == 'true' or '$(SkipClean)' == 'true') "
- TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
- BuildUri="$(BuildUri)"
- Name="$(WorkspaceName)"
- DeleteLocalItems="false" />
- <!-- Create the workspace for this build -->
- <CreateWorkspaceTask
- TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
- BuildUri="$(BuildUri)"
- BuildDirectory="$(BuildDirectory)"
- SourcesDirectory="$(SolutionRoot)"
- Name="$(WorkspaceName)"
- Comment="$(CreateWorkspaceTaskComment)">
- <Output TaskParameter="Name" PropertyName="WorkspaceName" />
- <Output TaskParameter="Owner" PropertyName="WorkspaceOwner" />
- </CreateWorkspaceTask>
- </Target>
- <!-- Override this target to execute custom tasks before getting sources -->
- <Target Name="BeforeGet" />
- <PropertyGroup>
- <GetDependsOn>
- BeforeGet;
- CoreGet;
- AfterGet;
- </GetDependsOn>
- </PropertyGroup>
- <!-- Batch target for getting sources -->
- <Target Name="Get"
- DependsOnTargets="$(GetDependsOn)" />
- <!-- Override this target to execute custom tasks after getting sources -->
- <Target Name="AfterGet" />
- <PropertyGroup>
- <CoreGetDependsOn/>
- </PropertyGroup>
- <Target Name="CoreGet"
- Condition=" '$(SkipGet)'!='true' and '$(IsDesktopBuild)'!='true' "
- DependsOnTargets="$(CoreGetDependsOn)" >
- <!-- Get the sources for the given workspace-->
- <Get TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
- BuildUri="$(BuildUri)"
- Workspace="$(WorkspaceName)"
- Version="$(GetVersion)"
- Filespec="$(GetFilespec)"
- PopulateOutput="$(GetPopulateOutput)"
- Overwrite="$(GetOverwrite)"
- Preview="$(PreviewGet)"
- Recursive="$(RecursiveGet)"
- Force="$(ForceGet)"
- Condition=" '$(ProjectFileVersion)' == '2' ">
- <Output TaskParameter="Gets" ItemName="Gets" />
- <Output TaskParameter="Replaces" ItemName="Replaces" />
- <Output TaskParameter="Deletes" ItemName="Deletes" />
- <Output TaskParameter="Warnings" ItemName="GetWarnings" />
- </Get>
- <Get TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
- BuildUri="$(BuildUri)"
- Workspace="$(WorkspaceName)"
- Version="$(GetVersion)"
- Filespec="$(GetFilespec)"
- PopulateOutput="$(GetPopulateOutput)"
- Overwrite="$(GetOverwrite)"
- Preview="$(PreviewGet)"
- Recursive="$(RecursiveGet)"
- Force="$(ForceGet)"
- AllowUnmapped="$(GetAllowUnmapped)"
- AutoMerge="$(GetAutoMerge)"
- NoCIOption="$(GetNoCIOption)"
- BuildDirectory="$(BuildDirectory)"
- Condition=" '$(ProjectFileVersion)' != '2' ">
- <Output TaskParameter="Gets" ItemName="Gets" />
- <Output TaskParameter="Replaces" ItemName="Replaces" />
- <Output TaskParameter="Deletes" ItemName="Deletes" />
- <Output TaskParameter="Warnings" ItemName="GetWarnings" />
- </Get>
- <SetBuildProperties Condition=" '$(GetVersion)' != '$(SourceGetVersion)' "
- TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
- BuildUri="$(BuildUri)"
- SourceGetVersion="$(GetVersion)" />
- <PropertyGroup>
- <SourceGetVersion>$(GetVersion)</SourceGetVersion>
- </PropertyGroup>
- </Target>
- <!-- Override this target to execute custom tasks before labeling sources -->
- <Target Name="BeforeLabel" />
- <PropertyGroup>
- <LabelDependsOn>
- BeforeLabel;
- CoreLabel;
- AfterLabel;
- </LabelDependsOn>
- </PropertyGroup>
- <!-- Batch target for labeling sources -->
- <Target Name="Label"
- DependsOnTargets="$(LabelDependsOn)" />
- <!-- Override this target to execute custom tasks after labeling sources -->
- <Target Name="AfterLabel" />
- <PropertyGroup>
- <CoreLabelDependsOn/>
- </PropertyGroup>
- <Target Name="CoreLabel"
- Condition=" '$(SkipLabel)'!='true' and '$(IsDesktopBuild)'!='true' "
- DependsOnTargets="$(CoreLabelDependsOn)" >
- <!-- The VersionSpec to be used by the Label task. Set it here to pick up any WorkspaceName overrides. -->
- <PropertyGroup>
- <LabelVersion Condition=" '$(LabelVersion)'=='' ">W$(WorkspaceName)</LabelVersion>
- </PropertyGroup>
- <!-- Label the latest sources in the workspace -->
- <Label TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
- BuildUri="$(BuildUri)"
- Name="$(LabelName)"
- Scope="$(LabelScope)"
- Version="$(LabelVersion)"
- Files="$(LabelFiles)"
- Child="$(LabelChild)"
- Comments="$(LabelComment)"
- Recursive="$(LabelRecursive)">
- <Output TaskParameter="Name" PropertyName="LabelName" />
- </Label>
- <!-- Set the build's LabelName property -->
- <SetBuildProperties
- TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
- BuildUri="$(BuildUri)"
- LabelName="$(LabelName)@$(LabelScope)" />
- </Target>
- <!-- Override this target to execute custom tasks before compilation -->
- <Target Name="BeforeCompile" />
- <PropertyGroup>
- <CompileDependsOn>
- BeforeCompile;
- CallCompile;
- AfterCompile;
- </CompileDependsOn>
- </PropertyGroup>
- <!-- Batch target for compilation -->
- <Target Name="Compile"
- DependsOnTargets="$(CompileDependsOn)" />
- <!-- Override this target to execute custom tasks after compilation -->
- <Target Name="AfterCompile" />
- <!-- Call CoreCompile via an MSBuild Task to ensure that ComputeConfigurationList gets executed. -->
- <PropertyGroup>
- <!-- Backwards Compatibility
- Make sure the CoreCompileDependsOn targets are executed in the main MSBuild call (not in a task invocation).
- -->
- <CoreCompileDependsOn />
- </PropertyGroup>
- <Target Name="CallCompile"
- DependsOnTargets="$(CoreCompileDependsOn)">
- <!-- Backwards Compatibility
- In Team Build v1 the OutDir property would remain set to its value for the final item in the ConfigurationToBuild
- item group for the duration of the build. These two property declarations mimic this behavior for backwards
- compatibility, to preserve support for the approach laid out in the MSDN article at:
- http://msdn2.microsoft.com/en-us/library/ms404859.aspx
- A better approach for this version of Microsoft.TeamFoundation.Build.targets would be to use the OutDir property
- for a particular configuration by overriding BeforeCompileConfiguration / AfterCompileConfiguration or
- BeforeCompileSolution / AfterCompileSolution. In these targets, OutDir will be set to the output directory for
- the current item in the ConfigurationToBuild item group.
- -->
- <PropertyGroup>
- <OutDir Condition=" '%(ConfigurationToBuild.PlatformToBuild)' != 'Any CPU' ">$(BinariesRoot)\%(ConfigurationToBuild.PlatformToBuild)\%(ConfigurationToBuild.FlavorToBuild)\\cf1 </OutDir>
- <OutDir Condition=" '%(ConfigurationToBuild.PlatformToBuild)' == 'Any CPU' ">$(BinariesRoot)\%(ConfigurationToBuild.FlavorToBuild)\\cf1 </OutDir>
- </PropertyGroup>
- <!-- Pass in all properties that users might want during the course of the compile targets. -->
- <MSBuild Projects="$(MSBuildProjectFile)"
- Properties="BuildAgentName=$(BuildAgentName);BuildAgentUri=$(BuildAgentUri);BuildDefinitionName=$(BuildDefinitionName);BuildDefinitionUri=$(BuildDefinitionUri);
- BuildDirectory=$(BuildDirectory);BuildNumber=$(BuildNumber);CompilationStatus=$(CompilationStatus);CompilationSuccess=$(CompilationSuccess);
- ConfigurationFolderUri=$(ConfigurationFolderUri);DropLocation=$(DropLocation);
- FullLabelName=$(FullLabelName);LastChangedBy=$(LastChangedBy);LastChangedOn=$(LastChangedOn);LogLocation=$(LogLocation);
- MachineName=$(MachineName);MaxProcesses=$(MaxProcesses);Port=$(Port);Quality=$(Quality);Reason=$(Reason);RequestedBy=$(RequestedBy);RequestedFor=$(RequestedFor);
- SourceGetVersion=$(SourceGetVersion);StartTime=$(StartTime);Status=$(Status);TeamProject=$(TeamProject);TestStatus=$(TestStatus);
- TestSuccess=$(TestSuccess);WorkspaceName=$(WorkspaceName);WorkspaceOwner=$(WorkspaceOwner);
- SolutionRoot=$(SolutionRoot);BinariesRoot=$(BinariesRoot);TestResultsRoot=$(TestResultsRoot);
- $(CustomPropertiesForBuild)"
- Targets="CoreCompile">
- <Output TaskParameter="TargetOutputs" ItemName="CompilationOutputs" />
- </MSBuild>
- <OnError ExecuteTargets="SetBuildBreakProperties;OnBuildBreak;" />
- </Target>
- <PropertyGroup>
- <_CoreCompileDependsOn>
- ComputeConfigurationList;
- </_CoreCompileDependsOn>
- </PropertyGroup>
- <!-- Main compile target -->
- <Target Name="CoreCompile"
- DependsOnTargets="$(_CoreCompileDependsOn)"
- Outputs="@(CompilationOutputs)">
- <MakeDir Directories="$(BinariesRoot)" Condition="!Exists('$(BinariesRoot)')" />
- <MSBuild BuildInParallel="$(BuildConfigurationsInParallel)"
- Projects="@(ConfigurationList)"
- Targets="CompileConfiguration"
- StopOnFirstFailure="$(StopOnFirstFailure)">
- <Output TaskParameter="TargetOutputs" ItemName="CompilationOutputs" />
- </MSBuild>
- </Target>
- <!-- Override this target to execute custom tasks before the compilation of an individual configuration -->
- <Target Name="BeforeCompileConfiguration" />
- <PropertyGroup>
- <CompileConfigurationDependsOn>
- BeforeCompileConfiguration;
- CoreCompileConfiguration;
- AfterCompileConfiguration;
- </CompileConfigurationDependsOn>
- </PropertyGroup>
- <!-- Batch target for individual configuration compilation -->
- <Target Name="CompileConfiguration"
- DependsOnTargets="$(CompileConfigurationDependsOn)"
- Outputs="@(CompilationOutputs)" />
- <!-- Override this target to execute custom tasks after the compilation of an individual configuration -->
- <Target Name="AfterCompileConfiguration" />
- <PropertyGroup>
- <CoreCompileConfigurationDependsOn>
- ComputeSolutionList;
- </CoreCompileConfigurationDependsOn>
- </PropertyGroup>
- <!-- Compile an individual configuration -->
- <Target Name="CoreCompileConfiguration" DependsOnTargets="$(CoreCompileConfigurationDependsOn)">
- <MSBuild BuildInParallel="$(BuildSolutionsInParallel)"
- Projects="@(SolutionList)"
- Targets="CompileSolution"
- StopOnFirstFailure="$(StopOnFirstFailure)">
- <Output TaskParameter="TargetOutputs" ItemName="CompilationOutputs" />
- </MSBuild>
- <!-- Add Platform and Configuration metadata to CompilationOutputs. -->
- <ItemGroup>
- <CompilationOutputs>
- <Platform>$(Platform)</Platform>
- <Configuration>$(Configuration)</Configuration>
- </CompilationOutputs>
- </ItemGroup>
- </Target>
- <!-- Override this target to execute custom tasks before the compilation of an individual solution -->
- <Target Name="BeforeCompileSolution" />
- <PropertyGroup>
- <CompileSolutionDependsOn>
- BeforeCompileSolution;
- CoreCompileSolution;
- AfterCompileSolution;
- </CompileSolutionDependsOn>
- </PropertyGroup>
- <!-- Batch target for individual solution compilation. -->
- <Target Name="CompileSolution"
- DependsOnTargets="$(CompileSolutionDependsOn)"
- Outputs="@(CompilationOutputs)" />
- <!-- Override this target to execute custom tasks after the compilation of an individual solution -->
- <Target Name="AfterCompileSolution" />
- <!-- Compile an individual solution -->
- <PropertyGroup>
- <!-- This property is used by FxCopTask to determine whether it is being used within Team Build. -->
- <TeamBuildConstants>_TEAM_BUILD_</TeamBuildConstants>
- </PropertyGroup>
- <Target Name="CoreCompileSolution">
- <PropertyGroup>
- <CodeAnalysisOption Condition=" '$(RunCodeAnalysis)'=='Always'">RunCodeAnalysis=true</CodeAnalysisOption>
- <VCOverridesCodeAnalysis Condition=" '$(RunCodeAnalysis)'=='Always'">%09%3CTool Name=%22VCCLCompilerTool%22 EnablePREfast=%22true%22 /%3E%0D%0A%09%3CTool Name=%22VCFxCopTool%22 EnableFxCop=%22true%22 /%3E%0D%0A</VCOverridesCodeAnalysis>
- <CodeAnalysisOption Condition=" '$(RunCodeAnalysis)'=='Never'">RunCodeAnalysis=false</CodeAnalysisOption>
- <VCOverridesCodeAnalysis Condition=" '$(RunCodeAnalysis)'=='Never'">%09%3CTool Name=%22VCCLCompilerTool%22 EnablePREfast=%22false%22 /%3E%0D%0A%09%3CTool Name=%22VCFxCopTool%22 EnableFxCop=%22false%22 /%3E%0D%0A</VCOverridesCodeAnalysis>
- <VsPropsFile Condition=" '$(Platform)' != 'Any CPU' ">$(Solution).$(Platform).$(Configuration).vsprops</VsPropsFile>
- <VsPropsFile Condition=" '$(Platform)' == 'Any CPU' ">$(Solution).$(Configuration).vsprops</VsPropsFile>
- <ReferencePathOption Condition=" '@(AdditionalReferencePath)'!='' ">ReferencePath=$(ReferencePath);@(AdditionalReferencePath)</ReferencePathOption>
- <OutDirOption Condition=" '$(CustomizableOutDir)' != 'true'">OutDir=$(TeamBuildOutDir)</OutDirOption>
- <PublishDirOption Condition=" '$(CustomizablePublishDir)' != 'true' ">PublishDir=$(TeamBuildPublishDir)</PublishDirOption>
- <FxCopDirOption Condition=" '$(FxCopDir)' != '' ">FxCopDir=$(FxCopDir)</FxCopDirOption>
- </PropertyGroup>
- <!-- Generate the VCOverride file for C++ projects -->
- <WriteLinesToFile Condition=" '$(CustomizableOutDir)' != 'true' "
- File="$(VsPropsFile)"
- Lines="$(VCOverridesOpen) OutputDirectory=%22$(OutDir)%22%3E%0D%0A$(VCOverridesCodeAnalysis)$(AdditionalVCOverrides)$(VCOverridesClose)"
- Overwrite="true" />
- <WriteLinesToFile Condition=" '$(CustomizableOutDir)' == 'true' "
- File="$(VsPropsFile)"
- Lines="$(VCOverridesOpen) %3E%0D%0A$(VCOverridesCodeAnalysis)$(AdditionalVCOverrides)$(VCOverridesClose)"
- Overwrite="true" />
- <!-- Build using MSBuild task -->
- <MSBuild BuildInParallel="$(BuildSolutionsInParallel)"
- Projects="$(Solution)"
- Properties="Configuration=$(Configuration);Platform=$(Platform);$(OutDirOption);$(PublishDirOption);SkipInvalidConfigurations=$(SkipInvalidConfigurations);$(FxCopDirOption);$(ReferencePathOption);$(CodeAnalysisOption);
- VCBuildOverride=$(VsPropsFile);VCBuildAdditionalLibPaths=$(VCBuildAdditionalLibPaths);VCBuildAdditionalOptions=$(VCBuildAdditionalOptions);VCBuildToolPath=$(VCBuildToolPath);VCBuildUseEnvironment=$(VCBuildUseEnvironment);
- TeamBuildConstants=$(TeamBuildConstants);TargetsNotLogged=$(TargetsNotLogged);$(CustomPropertiesForBuild);$(CustomProperties)"
- Targets="$(Targets)"
- StopOnFirstFailure="$(StopOnFirstFailure)">
- <Output TaskParameter="TargetOutputs" ItemName="CompilationOutputs" />
- </MSBuild>
- <!-- Add Solution metadata to CompilationOutputs. -->
- <ItemGroup>
- <CompilationOutputs>
- <Solution>$(Solution)</Solution>
- </CompilationOutputs>
- </ItemGroup>
- </Target>
- <PropertyGroup>
- <PostBuildDependsOn>
- GetChangesetsAndUpdateWorkItems;
- </PostBuildDependsOn>
- </PropertyGroup>
- <Target Name="PostBuild"
- Condition=" '$(SkipPostBuild)'!='true' and '$(IsDesktopBuild)'!='true' "
- DependsOnTargets="$(PostBuildDependsOn)" />
- <!-- Override this target to execute custom tasks before associating changesets and updating work items -->
- <Target Name="BeforeGetChangesetsAndUpdateWorkItems" />
- <PropertyGroup>
- <GetChangesetsAndUpdateWorkItemsDependsOn>
- BeforeGetChangesetsAndUpdateWorkItems;
- CoreGetChangesetsAndUpdateWorkItems;
- AfterGetChangesetsAndUpdateWorkItems;
- </GetChangesetsAndUpdateWorkItemsDependsOn>
- </PropertyGroup>
- <!-- Batch target for associating changesets and updating work items -->
- <Target Name="GetChangesetsAndUpdateWorkItems"
- DependsOnTargets="$(GetChangesetsAndUpdateWorkItemsDependsOn)" />
- <!-- Override this target to execute custom tasks after associating changesets and updating work items -->
- <Target Name="AfterGetChangesetsAndUpdateWorkItems" />
- <PropertyGroup>
- <CoreGetChangesetsAndUpdateWorkItemsDependsOn />
- </PropertyGroup>
- <Target Name="CoreGetChangesetsAndUpdateWorkItems"
- Condition=" '$(SkipGetChangesetsAndUpdateWorkItems)'!='true' "
- DependsOnTargets="$(CoreGetChangesetsAndUpdateWorkItemsDependsOn)">
- <GenCheckinNotesUpdateWorkItems
- TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
- BuildUri="$(BuildUri)"
- BuildNumber="$(BuildNumber)"
- CurrentLabel="$(LabelName)@$(LabelScope)"
- LastLabel="$(LastGoodBuildLabel)"
- UpdateWorkItems="$(UpdateAssociatedWorkItems)"
- ContinueOnError="true">
- <Output TaskParameter="AssociatedChangesets" ItemName="AssociatedChangesets" />
- </GenCheckinNotesUpdateWorkItems>
- </Target>
- <!-- Override this target to execute custom tasks before running tests -->
- <Target Name="BeforeTest" />
- <PropertyGroup>
- <TestDependsOn>
- BeforeTest;
- CoreTest;
- AfterTest;
- </TestDependsOn>
- </PropertyGroup>
- <!-- Batch target for running tests -->
- <Target Name="Test"
- DependsOnTargets="$(TestDependsOn)" />
- <!-- Override this target to execute custom tasks after running tests -->
- <Target Name="AfterTest" />
- <PropertyGroup>
- <CoreTestDependsOn/>
- </PropertyGroup>
- <!-- Run tests, if $(RunTest) is true -->
- <Target Name="CoreTest"
- DependsOnTargets="$(CoreTestDependsOn)" >
- <!-- Pass in all properties that users might want during the course of the test targets. -->
- <MSBuild Condition=" '$(RunTest)' == 'true' "
- Projects="$(MSBuildProjectFile)"
- Properties="BuildAgentName=$(BuildAgentName);BuildAgentUri=$(BuildAgentUri);BuildDefinitionName=$(BuildDefinitionName);BuildDefinitionUri=$(BuildDefinitionUri);
- BuildDirectory=$(BuildDirectory);BuildNumber=$(BuildNumber);CompilationStatus=$(CompilationStatus);CompilationSuccess=$(CompilationSuccess);
- ConfigurationFolderUri=$(ConfigurationFolderUri);DropLocation=$(DropLocation);
- FullLabelName=$(FullLabelName);LastChangedBy=$(LastChangedBy);LastChangedOn=$(LastChangedOn);LogLocation=$(LogLocation);
- MachineName=$(MachineName);MaxProcesses=$(MaxProcesses);Port=$(Port);Quality=$(Quality);Reason=$(Reason);RequestedBy=$(RequestedBy);RequestedFor=$(RequestedFor);
- SourceGetVersion=$(SourceGetVersion);StartTime=$(StartTime);Status=$(Status);TeamProject=$(TeamProject);TestStatus=$(TestStatus);
- TestSuccess=$(TestSuccess);WorkspaceName=$(WorkspaceName);WorkspaceOwner=$(WorkspaceOwner);
- SolutionRoot=$(SolutionRoot);BinariesRoot=$(BinariesRoot);TestResultsRoot=$(TestResultsRoot)"
- Targets="RunTest"
- StopOnFirstFailure="$(StopOnFirstFailure)">
- <Output TaskParameter="TargetOutputs" ItemName="TestOutputs" />
- </MSBuild>
- <!-- Refresh the test properties so that they can be used in AfterTest, etc. -->
- <GetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
- BuildUri="$(BuildUri)"
- Condition=" '$(IsDesktopBuild)' != 'true' ">
- <Output TaskParameter="TestStatus" PropertyName="TestStatus" />
- <Output TaskParameter="TestSuccess" PropertyName="TestSuccess" />
- </GetBuildProperties>
- <OnError ExecuteTargets="SetTestBreakProperties;OnBuildBreak" />
- </Target>
- <PropertyGroup>
- <RunTestDependsOn>
- ComputeConfigurationList;
- </RunTestDependsOn>
- </PropertyGroup>
- <!-- Run tests -->
- <Target Name="RunTest"
- DependsOnTargets="$(RunTestDependsOn)"
- Outputs="@(TestOutputs)">
- <MakeDir
- Directories="$(TestResultsRoot)"
- Condition="!Exists('$(TestResultsRoot)')" />
- <MSBuild Projects="@(ConfigurationList)"
- Properties="TreatTestFailureAsBuildFailure=$(TreatTestFailureAsBuildFailure)"
- Targets="TestConfiguration"
- StopOnFirstFailure="$(StopOnFirstFailure)">
- <Output TaskParameter="TargetOutputs" ItemName="TestOutputs" />
- </MSBuild>
- </Target>
- <!-- Override this target to execute custom tasks before the testing of an individual configuration -->
- <Target Name="BeforeTestConfiguration" />
- <PropertyGroup>
- <TestConfigurationDependsOn>
- BeforeTestConfiguration;
- CoreTestConfiguration;
- AfterTestConfiguration;
- </TestConfigurationDependsOn>
- </PropertyGroup>
- <!-- Batch target for individual configuration testing -->
- <Target Name="TestConfiguration"
- DependsOnTargets="$(TestConfigurationDependsOn)"
- Outputs="@(TestOutputs)" />
- <!-- Override this target to execute custom tasks after the testing of an individual configuration -->
- <Target Name="AfterTestConfiguration" />
- <Target Name="ResolveTestFilesForEndToEndIteration">
- <WorkspaceItemConverterTask
- Condition=" '@(MetaDataFile)' != '' and '$(IsDesktopBuild)' != 'true' "
- TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
- BuildUri="$(BuildUri)"
- WorkspaceName="$(WorkspaceName)"
- WorkspaceOwner="$(WorkspaceOwner)"
- ServerItems="@(MetaDataFile)">
- <Output TaskParameter="LocalItems" ItemName="LocalMetaDataFile" />
- </WorkspaceItemConverterTask>
- <WorkspaceItemConverterTask
- Condition=" '@(TestContainer)' != '' and '$(IsDesktopBuild)' != 'true' "
- TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
- BuildUri="$(BuildUri)"
- WorkspaceName="$(WorkspaceName)"
- WorkspaceOwner="$(WorkspaceOwner)"
- ServerItems="@(TestContainer)">
- <Output TaskParameter="LocalItems" ItemName="TempTestContainer" />
- </WorkspaceItemConverterTask>
- <!-- Expand TempTestContainer wild cards to create LocalTestContainer item that will be used later (this will replace * and ? with matching file paths)-->
- <CreateItem Include="@(TempTestContainer)" Condition=" '$(IsDesktopBuild)' != 'true' ">
- <Output TaskParameter="Include" ItemName="LocalTestContainer"/>
- </CreateItem>
- <CreateItem Include="@(TestContainer)" Condition=" '$(IsDesktopBuild)' == 'true' ">
- <Output TaskParameter="Include" ItemName="LocalTestContainer"/>
- </CreateItem>
- </Target>
- <!-- Test an individual configuration -->
- <PropertyGroup>
- <CoreTestConfigurationDependsOn>
- ResolveTestFilesForEndToEndIteration;
- </CoreTestConfigurationDependsOn>
- </PropertyGroup>
- <Target Name="CoreTestConfiguration"
- DependsOnTargets="$(CoreTestConfigurationDependsOn)"
- Outputs="@(TestOutputs)">
- <Warning Condition=" '$(V8TestToolsTask)'=='true' and '$(TestNames)'!='' "
- Text="Warning: The TestNames property cannot be used in in combination with the V8 TestToolsTask and will be ignored." />
- <Warning Condition=" '$(V8TestToolsTask)'=='true' and '@(LocalTestContainer)' != '' "
- Text="Warning: The TestContainer item group cannot be used in combination with the V8 TestToolsTask and will be ignored." />
- <PropertyGroup>
- <ContinueOnTestError Condition=" '$(StopOnTestFailure)' != 'true' ">true</ContinueOnTestError>
- <ContinueOnTestError Condition=" '$(StopOnTestFailure)' == 'true' ">false</ContinueOnTestError>
- </PropertyGroup>
- <!-- 10.0 MetaDataFile tests for non-desktop builds. -->
- <TestToolsTask
- Condition=" '$(ProjectFileVersion)' != '2' and '$(IsDesktopBuild)'!='true' and '$(V8TestToolsTask)'!='true' and '%(LocalMetaDataFile.Identity)' != '' "
- ToolPath="$(TestToolsTaskToolPath)"
- BuildFlavor="$(Configuration)"
- BuildUri="$(BuildUri)"
- Platform="$(Platform)"
- SearchPathRoot="$(OutDir)"
- PathToResultsFilesRoot="$(TestResultsRoot)"
- MetaDataFile="%(LocalMetaDataFile.Identity)"
- RunConfigFile="$(RunConfigFile)"
- TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
- TestLists="%(LocalMetaDataFile.TestList)"
- TeamProject="$(TeamProject)"
- TestNames="$(TestNames)"
- Publish="$(PublishTestResults)"
- ContinueOnError="$(ContinueOnTestError)" />
- <!-- 10.0 TestContainer tests for non-desktop builds. -->
- <TestToolsTask
- Condition=" '$(ProjectFileVersion)' != '2' and '$(IsDesktopBuild)'!='true' and '$(V8TestToolsTask)'!='true' and '@(LocalTestContainer)' != '' "
- ToolPath="$(TestToolsTaskToolPath)"
- BuildFlavor="$(Configuration)"
- BuildUri="$(BuildUri)"
- Platform="$(Platform)"
- SearchPathRoot="$(OutDir)"
- PathToResultsFilesRoot="$(TestResultsRoot)"
- RunConfigFile="$(RunConfigFile)"
- TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
- TestContainers="@(LocalTestContainer)"
- TeamProject="$(TeamProject)"
- TestNames="$(TestNames)"
- Publish="$(PublishTestResults)"
- ContinueOnError="$(ContinueOnTestError)" />
- <!-- 9.0 MetaDataFile tests for non-desktop builds. -->
- <TestToolsTask
- Condition=" '$(ProjectFileVersion)' == '2' and '$(IsDesktopBuild)'!='true' and '$(V8TestToolsTask)'!='true' and '%(LocalMetaDataFile.Identity)' != '' "
- BuildFlavor="$(Configuration)"
- Platform="$(Platform)"
- PublishServer="$(TeamFoundationServerUrl)"
- PublishBuild="$(BuildUri)"
- SearchPathRoot="$(OutDir)"
- PathToResultsFilesRoot="$(TestResultsRoot)"
- MetaDataFile="%(LocalMetaDataFile.Identity)"
- RunConfigFile="$(RunConfigFile)"
- TestLists="%(LocalMetaDataFile.TestList)"
- TeamProject="$(TeamProject)"
- TestNames="$(TestNames)"
- ContinueOnError="$(ContinueOnTestError)" />
- <!-- 8.0 MetaDataFile tests for non-desktop builds. -->
- <TestToolsTask
- Condition=" '$(IsDesktopBuild)'!='true' and '$(V8TestToolsTask)'=='true' and '%(LocalMetaDataFile.Identity)' != '' "
- BuildFlavor="$(Configuration)"
- Platform="$(Platform)"
- PublishServer="$(TeamFoundationServerUrl)"
- PublishBuild="$(BuildNumber)"
- SearchPathRoot="$(OutDir)"
- PathToResultsFilesRoot="$(TestResultsRoot)"
- MetaDataFile="%(LocalMetaDataFile.Identity)"
- RunConfigFile="$(RunConfigFile)"
- TestLists="%(LocalMetaDataFile.TestList)"
- TeamProject="$(TeamProject)"
- ContinueOnError="$(ContinueOnTestError)" />
- <!-- 9.0 TestContainer tests for non-desktop builds. -->
- <TestToolsTask
- Condition=" '$(ProjectFileVersion)' == '2' and '$(IsDesktopBuild)'!='true' and '$(V8TestToolsTask)'!='true' and '@(LocalTestContainer)' != '' "
- BuildFlavor="$(Configuration)"
- Platform="$(Platform)"
- PublishServer="$(TeamFoundationServerUrl)"
- PublishBuild="$(BuildUri)"
- SearchPathRoot="$(OutDir)"
- PathToResultsFilesRoot="$(TestResultsRoot)"
- RunConfigFile="$(RunConfigFile)"
- TestContainers="@(LocalTestContainer)"
- TeamProject="$(TeamProject)"
- TestNames="$(TestNames)"
- ContinueOnError="$(ContinueOnTestError)" />
- <!-- 10.0/9.0 MetaDataFile tests for desktop builds. -->
- <TestToolsTask
- Condition=" '$(IsDesktopBuild)'=='true' and '$(V8TestToolsTask)'!='true' and '%(MetaDataFile.Identity)' != '' "
- ToolPath="$(TestToolsTaskToolPath)"
- SearchPathRoot="$(OutDir)"
- PathToResultsFilesRoot="$(TestResultsRoot)"
- MetaDataFile="%(MetaDataFile.Identity)"
- RunConfigFile="$(RunConfigFile)"
- TestLists="%(MetaDataFile.TestList)"
- TestNames="$(TestNames)"
- ContinueOnError="$(ContinueOnTestError)" />
- <!-- 8.0 MetaDataFile tests for desktop builds. -->
- <TestToolsTask
- Condition=" '$(IsDesktopBuild)'=='true' and '$(V8TestToolsTask)'=='true' and '%(MetaDataFile.Identity)' != '' "
- SearchPathRoot="$(OutDir)"
- PathToResultsFilesRoot="$(TestResultsRoot)"
- MetaDataFile="%(MetaDataFile.Identity)"
- RunConfigFile="$(RunConfigFile)"
- TestLists="%(MetaDataFile.TestList)"
- ContinueOnError="$(ContinueOnTestError)" />
- <!-- 10.0/9.0 TestContainer tests for desktop builds. -->
- <TestToolsTask
- Condition=" '$(IsDesktopBuild)'=='true' and '$(V8TestToolsTask)'!='true' and '@(LocalTestContainer)' != '' "
- ToolPath="$(TestToolsTaskToolPath)"
- SearchPathRoot="$(OutDir)"
- PathToResultsFilesRoot="$(TestResultsRoot)"
- RunConfigFile="$(RunConfigFile)"
- TestContainers="@(LocalTestContainer)"
- TestNames="$(TestNames)"
- ContinueOnError="$(ContinueOnTestError)" />
- <!-- Populate TestOutputs with MetaData Files and Test Containers. -->
- <ItemGroup>
- <!-- TestContainer tests for non-desktop and desktop builds. -->
- <TestOutputs Condition=" '@(LocalTestContainer)' != '' "
- Include="%(LocalTestContainer.Identity)">
- <Platform>$(Platform)</Platform>
- <Configuration>$(Configuration)</Configuration>
- </TestOutputs>
- <!-- MetaDataFile tests for non-desktop builds. -->
- <TestOutputs Condition=" '$(IsDesktopBuild)'!='true' and '%(LocalMetaDataFile.Identity)' != '' "
- Include="%(LocalMetaDataFile.Identity)">
- <Platform>$(Platform)</Platform>
- <Configuration>$(Configuration)</Configuration>
- </TestOutputs>
- <!-- MetaDataFile tests for desktop builds. -->
- <TestOutputs Condition=" '$(IsDesktopBuild)'=='true' and '%(MetaDataFile.Identity)' != '' "
- Include="%(MetaDataFile.Identity)">
- <Platform>$(Platform)</Platform>
- <Configuration>$(Configuration)</Configuration>
- </TestOutputs>
- </ItemGroup>
- </Target>
- <!-- Override this target to generate documentation. -->
- <Target Name="GenerateDocumentation" />
- <!-- Override this target to package all binaries for deployment. -->
- <Target Name="PackageBinaries" />
- <!-- Override this target to execute custom tasks before copying files to the drop location -->
- <Target Name="BeforeDropBuild" />
- <PropertyGroup>
- <DropBuildDependsOn>
- BeforeDropBuild;
- CoreDropBuild;
- AfterDropBuild;
- </DropBuildDependsOn>
- </PropertyGroup>
- <!-- Batch target for copying files to the drop location -->
- <Target Name="DropBuild"
- DependsOnTargets="$(DropBuildDependsOn)" />
- <!-- Override this target to execute custom tasks after copying files to the drop location -->
- <Target Name="AfterDropBuild" />
- <PropertyGroup>
- <CoreDropBuildDependsOn />
- </PropertyGroup>
- <Target Name="CoreDropBuild"
- Condition=" '$(SkipDropBuild)'!='true' and '$(IsDesktopBuild)'!='true' "
- DependsOnTargets="$(CoreDropBuildDependsOn)" >
- <ItemGroup>
- <FilesToCopy Include="$(BinariesRoot)\**\*.*" />
- </ItemGroup>
- <Copy Condition=" '$(BuildBreak)'!='true' "
- SourceFiles="@(FilesToCopy)"
- DestinationFiles="@(FilesToCopy ->'$(DropLocation)\$(BuildNumber)\%(RecursiveDir)%(Filename)%(Extension)')" />
- <Copy Condition=" '$(BuildBreak)'=='true' "
- SourceFiles="@(FilesToCopy)"
- DestinationFiles="@(FilesToCopy ->'$(DropLocation)\$(BuildNumber)\%(RecursiveDir)%(Filename)%(Extension)')"
- ContinueOnError="true" />
- </Target>
- <!-- Override this target to execute custom tasks before reverting the workspace -->
- <Target Name="BeforeRevertWorkspace" />
- <PropertyGroup>
- <RevertWorkspaceDependsOn>
- BeforeRevertWorkspace;
- CoreRevertWorkspace;
- AfterRevertWorkspace;
- </RevertWorkspaceDependsOn>
- </PropertyGroup>
- <!-- Batch target for reverting the workspace after a shelveset build -->
- <Target Name="RevertWorkspace"
- DependsOnTargets="$(RevertWorkspaceDependsOn)" />
- <!-- Override this target to execute custom tasks after reverting the workspace -->
- <Target Name="AfterRevertWorkspace" />
- <PropertyGroup>
- <CoreRevertWorkspaceDependsOn />
- </PropertyGroup>
- <Target Name="CoreRevertWorkspace"
- Condition=" '$(IsDesktopBuild)' != 'true' and '$(ProjectFileVersion)' != '2' and ('$(Reason)' == 'CheckinShelveset' or '$(Reason)' == 'ValidateShelveset') "
- DependsOnTargets="$(CoreRevertWorkspaceDependsOn)">
- <RevertWorkspaceTask TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
- BuildUri="$(BuildUri)"
- WorkspaceName="$(WorkspaceName)"
- WorkspaceOwner="$(WorkspaceOwner)" />
- </Target>
- <!-- Set the TestBreak property to true. -->
- <Target Name="SetTestBreakProperties">
- <PropertyGroup>
- <TestBreak>true</TestBreak>
- </PropertyGroup>
- <!-- Refresh the test properties so that they can be used in AfterTestBreak, etc. -->
- <GetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
- BuildUri="$(BuildUri)"
- Condition=" '$(IsDesktopBuild)' != 'true' ">
- <Output TaskParameter="TestStatus" PropertyName="TestStatus" />
- <Output TaskParameter="TestSuccess" PropertyName="TestSuccess" />
- </GetBuildProperties>
- </Target>
- <!-- Set the BuildBreak property to true. -->
- <Target Name="SetBuildBreakProperties">
- <PropertyGroup>
- <BuildBreak>true</BuildBreak>
- </PropertyGroup>
- <!-- Refresh the compilation properties so that they can be used in AfterBuildBreak, etc. -->
- <GetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
- BuildUri="$(BuildUri)"
- Condition=" '$(IsDesktopBuild)' != 'true' ">
- <Output TaskParameter="CompilationStatus" PropertyName="CompilationStatus" />
- <Output TaskParameter="CompilationSuccess" PropertyName="CompilationSuccess" />
- </GetBuildProperties>
- </Target>
- <!-- Override this target to execute custom tasks before the BuildBreak target -->
- <Target Name="BeforeOnBuildBreak" />
- <PropertyGroup>
- <OnBuildBreakDependsOn>
- BeforeOnBuildBreak;
- CoreOnBuildBreak;
- AfterOnBuildBreak;
- </OnBuildBreakDependsOn>
- </PropertyGroup>
- <Target Name="OnBuildBreak"
- Condition=" '$(IsDesktopBuild)'!='true' "
- DependsOnTargets="$(OnBuildBreakDependsOn)" />
- <!-- Override this target to execute custom tasks after the BuildBreak target -->
- <Target Name="AfterOnBuildBreak" />
- <PropertyGroup>
- <CoreOnBuildBreakDependsOn>
- GetChangesetsOnBuildBreak;
- DropBuild;
- CreateWorkItem;
- RevertWorkspace;
- </CoreOnBuildBreakDependsOn>
- </PropertyGroup>
- <Target Name="CoreOnBuildBreak"
- DependsOnTargets="$(CoreOnBuildBreakDependsOn)" />
- <!-- Override the target to execute custom tasks before associating changesets on a build break -->
- <Target Name="BeforeGetChangesetsOnBuildBreak" />
- <PropertyGroup>
- <GetChangesetsOnBuildBreakDependsOn>
- BeforeGetChangesetsOnBuildBreak;
- CoreGetChangesetsOnBuildBreak;
- AfterGetChangesetsOnBuildBreak;
- </GetChangesetsOnBuildBreakDependsOn>
- </PropertyGroup>
- <!-- Batch target for associating changesets on a build break -->
- <Target Name="GetChangesetsOnBuildBreak"
- Condition=" '$(BuildBreak)' == 'true' "
- DependsOnTargets="$(GetChangesetsOnBuildBreakDependsOn)" />
- <!-- Override the target to execute custom tasks after associating changesets on a build break -->
- <Target Name="AfterGetChangesetsOnBuildBreak" />
- <PropertyGroup>
- <CoreGetChangesetsOnBuildBreakDependsOn />
- </PropertyGroup>
- <Target Name="CoreGetChangesetsOnBuildBreak"
- Condition=" '$(IsDesktopBuild)'!='true' and
- '$(SkipGetChangesetsAndUpdateWorkItems)'!='true' "
- DependsOnTargets="$(CoreGetChangesetsOnBuildBreakDependsOn)">
- <GenCheckinNotesUpdateWorkItems
- TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
- BuildUri="$(BuildUri)"
- BuildNumber="$(BuildNumber)"
- CurrentLabel="$(LabelName)@$(LabelScope)"
- LastLabel="$(LastGoodBuildLabel)"
- UpdateWorkItems="$(UpdateAssociatedWorkItemsOnBuildBreak)"
- ContinueOnError="true" />
- </Target>
- <!-- Override this target to execute custom tasks before work item creation -->
- <Target Name="BeforeCreateWorkItem" />
- <PropertyGroup>
- <CreateWorkItemDependsOn>
- BeforeCreateWorkItem;
- CoreCreateWorkItem;
- AfterCreateWorkItem;
- </CreateWorkItemDependsOn>
- </PropertyGroup>
- <!-- Batch target for work item creation -->
- <Target Name="CreateWorkItem"
- DependsOnTargets="$(CreateWorkItemDependsOn)"/>
- <!-- Override this target to execute custom tasks after work item creation-->
- <Target Name="AfterCreateWorkItem" />
- <PropertyGroup>
- <CoreCreateWorkItemDependsOn />
- </PropertyGroup>
- <Target Name="CoreCreateWorkItem"
- Condition=" '$(SkipWorkItemCreation)'!='true' and '$(IsDesktopBuild)'!='true' "
- DependsOnTargets="$(CoreCreateWorkItemDependsOn)">
- <PropertyGroup>
- <WorkItemTitle>$(WorkItemTitle) $(BuildNumber)</WorkItemTitle>
- <BuildLogText>$(BuildlogText) <a href='file:///$(DropLocation)\$(BuildNumber)\BuildLog.txt'>$(DropLocation)\$(BuildNumber)\BuildLog.txt</a >.</BuildLogText>
- <ErrorWarningLogText Condition="!Exists('$(MSBuildProjectDirectory)\ErrorsWarningsLog.txt')"></ErrorWarningLogText>
- <ErrorWarningLogText Condition="Exists('$(MSBuildProjectDirectory)\ErrorsWarningsLog.txt')">$(ErrorWarningLogText) <a href='file:///$(DropLocation)\$(BuildNumber)\ErrorsWarningsLog.txt'>$(DropLocation)\$(BuildNumber)\ErrorsWarningsLog.txt</a >.</ErrorWarningLogText>
- <WorkItemDescription>$(DescriptionText) %3CBR%2F%3E $(BuildlogText) %3CBR%2F%3E $(ErrorWarningLogText)</WorkItemDescription>
- </PropertyGroup>
- <CreateNewWorkItem
- TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
- BuildUri="$(BuildUri)"
- BuildNumber="$(BuildNumber)"
- Description="$(WorkItemDescription)"
- TeamProject="$(TeamProject)"
- Title="$(WorkItemTitle)"
- WorkItemFieldValues="$(WorkItemFieldValues)"
- WorkItemType="$(WorkItemType)"
- ContinueOnError="true" />
- </Target>
- <!-- Compute the list of all Platform / Configuration combinations -->
- <Target Name="ComputeConfigurationList">
- <ItemGroup>
- <!-- ConfigurationList for any Platform but Any CPU -->
- <ConfigurationList Condition=" '%(ConfigurationToBuild.PlatformToBuild)' != 'Any CPU' " Include="$(MSBuildProjectFile)">
- <Properties>Configuration=%(ConfigurationToBuild.FlavorToBuild);Platform=%(ConfigurationToBuild.PlatformToBuild);TeamBuildOutDir=$(BinariesRoot)\%(ConfigurationToBuild.PlatformToBuild)\%(ConfigurationToBuild.FlavorToBuild)\;TeamBuildPublishDir=$(BinariesRoot)\%(ConfigurationToBuild.PlatformToBuild)\%(ConfigurationToBuild.FlavorToBuild)\\cf1 </Properties>
- </ConfigurationList>
- <!-- ConfigurationList for Any CPU Platform -->
- <ConfigurationList Condition=" '%(ConfigurationToBuild.PlatformToBuild)' == 'Any CPU' " Include="$(MSBuildProjectFile)">
- <Properties>Configuration=%(ConfigurationToBuild.FlavorToBuild);Platform=%(ConfigurationToBuild.PlatformToBuild);TeamBuildOutDir=$(BinariesRoot)\%(ConfigurationToBuild.FlavorToBuild)\;TeamBuildPublishDir=$(BinariesRoot)\%(ConfigurationToBuild.FlavorToBuild)\\cf1 </Properties>
- </ConfigurationList>
- </ItemGroup>
- </Target>
- <Target Name="ResolveSolutionPathsForDesktopBuild"
- Condition=" '$(IsDesktopBuild)' == 'true' ">
- <ItemGroup>
- <LocalSolutionToBuild Include="@(SolutionToBuild)" />
- <LocalSolutionToPublish Include="@(SolutionToPublish)" />
- </ItemGroup>
- </Target>
- <Target Name="ResolveSolutionPathsForEndToEndIteration"
- Condition=" '$(IsDesktopBuild)' != 'true' ">
- <WorkspaceItemConverterTask
- Condition=" '@(SolutionToBuild)' != '' "
- TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
- BuildUri="$(BuildUri)"
- WorkspaceName="$(WorkspaceName)"
- WorkspaceOwner="$(WorkspaceOwner)"
- ServerItems="@(SolutionToBuild)">
- <Output TaskParameter="LocalItems" ItemName="LocalSolutionToBuild" />
- </WorkspaceItemConverterTask>
- <WorkspaceItemConverterTask
- Condition=" '@(SolutionToPublish)' != '' "
- TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
- BuildUri="$(BuildUri)"
- WorkspaceName="$(WorkspaceName)"
- WorkspaceOwner="$(WorkspaceOwner)"
- ServerItems="@(SolutionToPublish)">
- <Output TaskParameter="LocalItems" ItemName="LocalSolutionToPublish" />
- </WorkspaceItemConverterTask>
- </Target>
- <!-- Compute the list of all Solutions (for each Platform / Configuration combination) -->
- <PropertyGroup>
- <ComputeSolutionListDependsOn>
- ResolveSolutionPathsForDesktopBuild;
- ResolveSolutionPathsForEndToEndIteration;
- </ComputeSolutionListDependsOn>
- </PropertyGroup>
- <Target Name="ComputeSolutionList"
- DependsOnTargets="$(ComputeSolutionListDependsOn)">
- <ItemGroup>
- <!-- SolutionToBuild -->
- <SolutionList Condition=" '@(LocalSolutionToBuild)' != '' " Include="$(MSBuildProjectFile)">
- <Properties>Solution=%(LocalSolutionToBuild.Identity);Targets=%(LocalSolutionToBuild.Targets);CustomProperties=%(LocalSolutionToBuild.Properties)</Properties>
- </SolutionList>
- <!-- Maintain support for SolutionToPublish -->
- <SolutionList Condition=" '@(LocalSolutionToPublish)' != '' " Include="$(MSBuildProjectFile)">
- <Properties>Solution=%(LocalSolutionToPublish.Identity);Targets=Publish;CustomProperties=%(LocalSolutionToPublish.Properties)</Properties>
- </SolutionList>
- </ItemGroup>
- </Target>
- <PropertyGroup>
- <GetImpactedTestsDependsOn />
- </PropertyGroup>
- <Target Name="GetImpactedTests"
- DependsOnTargets="$(GetImpactedTestsDependsOn)"
- Condition=" '$(ProjectFileVersion)' != '2' and '$(PerformTestImpactAnalysis)' == 'true' and '$(IsDesktopBuild)' != 'true' and '@(CompilationOutputs)' != '' and '@(AssociatedChangesets)' != '' ">
- <GetImpactedTests
- TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
- BuildUri="$(BuildUri)"
- BuildBinariesRoot="$(BinariesRoot)"
- Assemblies="@(CompilationOutputs)"
- WorkspaceName="$(WorkspaceName)"
- Changesets="@(AssociatedChangesets)"
- >
- <Output TaskParameter="CodeChanges" ItemName="CodeChanges" />
- <Output TaskParameter="ImpactedTests" ItemName="ImpactedTests" />
- </GetImpactedTests>
- </Target>
- </Project>
让我们来完整的阅读并理解这个文件, 比较痛苦而且没有必要. 我们只需要知道:
1. UsingTask. UsingTask标签表示引入一个指定程序集(AssemblyFile)中的特定功能(TaskName). 作用就是在某处被用来告诉MSBuild引擎执行该指定功能完成一个特定操作.
2. Targets. 这些Targets就是微软定义的Team Build 流程中的各个步骤. 各个Target的执行顺序, 并不是Target在该文件中的书写顺序, 而是依赖于显式指出的DependsOnTargets属性(Attribute). 这是MSBuild的特性, MSbuild引擎会统揽所有Target及其DependsOnTargets属性, 从而推断出一条唯一的执行顺序(完全无依赖关系的两个Target将以书写顺序执行).
微软根据自己的判断, 在执行流程的不同阶段提供了许多未实现具体逻辑的空白Target, 并推荐用户来重写这些Target. Microsoft.TeamFoundation.Build.targets文件大多数时候是隐藏在团队项目后面的, 而且微软极不推荐直接修改这个文件因为它会影响所有在这个生成服务器上生成的团队项目的流程. 在我们为一个团队项目添加生成定义的时候, 在我们的团队项目源代码里面$/<TeamProject>/TeamBuildTypes/<TeamBuildDefinitionName>目录下添加了一个名叫<TFSBuild.proj>的文件, 这个文件才是用来提供给我们做自定义修改的. 现在这个未修改的文件中除了一些默认定义的属性和元组外, 只有我们在创建团队生成类型定义时, 指定的需要编译的源代码方案.
- <?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">
- <!-- Do not edit this -->
- <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\TeamBuild\Microsoft.TeamFoundation.Build.targets" />
- <ProjectExtensions>
- <!-- Team Foundation Build Version - DO NOT CHANGE -->
- <ProjectFileVersion>2</ProjectFileVersion>
- <!--DESCRIPTION
- This property is included only for backwards compatibility. The description of a build definition
- is now stored in the database. For compatibility with V1 clients, keep this property in sync with
- the value in the database.
- -->
- <Description></Description>
- <!--BUILD MACHINE
- This property is included only for backwards compatibility. The default machine used for a build
- definition is now stored in the database, as the MachineName property of the definition's
- DefaultBuildAgent. For compatibility with V1 clients, keep this property in sync with the value
- in the database.
- -->
- <BuildMachine>WIN-IFZXCKFO2L8</BuildMachine>
- </ProjectExtensions>
- <PropertyGroup>
- <!--TEAM PROJECT
- This property is included only for backwards compatibility. The team project for a build
- definition is now stored in the database. For compatibility with V1 clients, keep this property in
- sync with the value in the database.
- -->
- <TeamProject>Sun</TeamProject>
- <!--BUILD DIRECTORY
- This property is included only for backwards compatibility. The build directory used for a build
- definition is now stored in the database, as the BuildDirectory property of the definition's
- DefaultBuildAgent. For compatibility with V1 clients, keep this property in sync with the value
- in the database.
- -->
- <BuildDirectoryPath>C:\Builds\Sun\Empty</BuildDirectoryPath>
- <!--DROP LOCATION
- This property is included only for backwards compatibility. The drop location used for a build
- definition is now stored in the database. For compatibility with V1 clients, keep this property
- in sync with the value in the database.
- -->
- <DropLocation>\\UNKNOWN\drops</DropLocation>
- <!--TESTING
- Set this flag to enable/disable running tests as a post-compilation build step.
- -->
- <RunTest>true</RunTest>
- <!--CODE ANALYSIS
- Set this property to enable/disable running code analysis. Valid values for this property are
- Default, Always and Never.
- Default - Perform code analysis as per the individual project settings
- Always - Always perform code analysis irrespective of project settings
- Never - Never perform code analysis irrespective of project settings
- -->
- <RunCodeAnalysis>Never</RunCodeAnalysis>
- <!-- Additional Properties -->
- <!--WorkItemType
- The type of the work item created on a build failure.
- -->
- <WorkItemType>Bug</WorkItemType>
- <!--WorkItemFieldValues
- Fields and values of the work item created on a build failure.
- Note: Use reference names for fields if you want the build to be resistant to field name
- changes. Reference names are language independent while friendly names are changed depending
- on the installed language. For example, "System.Reason" is the reference name for the "Reason"
- field.
- -->
- <WorkItemFieldValues>System.Reason=Build Failure;System.Description=Start the build using Team Build</WorkItemFieldValues>
- <!--WorkItemTitle
- Title of the work item created on build failure.
- -->
- <WorkItemTitle>Build failure in build:</WorkItemTitle>
- <!--DescriptionText
- History comment of the work item created on a build failure.
- -->
- <DescriptionText>This work item was created by Team Build on a build failure.</DescriptionText>
- <!--BuildLogText
- Additional comment text for the work item created on a build failure.
- -->
- <BuildlogText>The build log file is at:</BuildlogText>
- <!--ErrorWarningLogText
- Additional comment text for the work item created on a build failure.
- This text will only be added if there were errors or warnings.
- -->
- <ErrorWarningLogText>The errors/warnings log file is at:</ErrorWarningLogText>
- <!--UpdateAssociatedWorkItems
- Set this flag to enable/disable updating associated workitems on a successful build.
- -->
- <UpdateAssociatedWorkItems>true</UpdateAssociatedWorkItems>
- <!--AdditionalVCOverrides
- Additional text for the VCOverrides file generated for VC++ projects.
- -->
- <AdditionalVCOverrides></AdditionalVCOverrides>
- <!--CustomPropertiesForClean
- Custom properties to pass to the MSBuild task while calling the "Clean" target for all solutions.
- The format should be: PropertyName1=value1;PropertyName2=value2;...
- -->
- <CustomPropertiesForClean></CustomPropertiesForClean>
- <!--CustomPropertiesForBuild
- Custom properties to pass to the MSBuild task while calling the default targets for all solutions.
- The format should be: Property1=value1;Property2=value2;... To pass custom properties to
- individual solutions, use the Properties metadata item of the SolutionToBuild ItemGroup.
- -->
- <CustomPropertiesForBuild></CustomPropertiesForBuild>
- </PropertyGroup>
- <ItemGroup>
- <!--SOLUTIONS
- The paths of the solutions to build. Paths can be server paths or local paths, but server paths
- relative to the location of this file are highly recommended. To add/delete solutions, edit this
- ItemGroup. For example, to add a solution MySolution.sln, add the following line:
- <SolutionToBuild Include="$(BuildProjectFolderPath)/path/MySolution.sln" />
- To change the order in which the solutions are built, modify the order in which the solutions
- appear below.
- To call a target (or targets) other than the default, add a metadata item named Targets. To pass
- custom properties to the solution, add a metadata item named Properties. For example, to call
- the targets MyCustomTarget1 and MyCustomTarget2, passing in properties Property1 and Property2,
- add the following:
- <SolutionToBuild Include="$(BuildProjectFolderPath)/path/MySolution.sln">
- <Targets>MyCustomTarget1;MyCustomTarget2</Targets>
- <Properties>Property1=Value1;Property2=Value2</Properties>
- </SolutionToBuild>
- -->
- <SolutionToBuild Include="$(BuildProjectFolderPath)/http://www.cnblogs.com/Trunk/Product/Sources/RI/StockTraderRI.sln">
- <Targets></Targets>
- <Properties></Properties>
- </SolutionToBuild>
- </ItemGroup>
- <ItemGroup>
- <!--CONFIGURATIONS
- The list of configurations to build. To add/delete configurations, edit this value. For example,
- to add a new configuration, add the following lines:
- <ConfigurationToBuild Include="Debug|x86">
- <FlavorToBuild>Debug</FlavorToBuild>
- <PlatformToBuild>x86</PlatformToBuild>
- </ConfigurationToBuild>
- The Include attribute value should be unique for each ConfigurationToBuild node.
- -->
- <ConfigurationToBuild Include="Release|Any CPU">
- <FlavorToBuild>Release</FlavorToBuild>
- <PlatformToBuild>Any CPU</PlatformToBuild>
- </ConfigurationToBuild>
- <ConfigurationToBuild Include="Debug|Any CPU">
- <FlavorToBuild>Debug</FlavorToBuild>
- <PlatformToBuild>Any CPU</PlatformToBuild>
- </ConfigurationToBuild>
- </ItemGroup>
- <ItemGroup>
- <!--TEST ARGUMENTS
- If the RunTest property is set to true then the following test arguments will be used to run
- tests. Tests can be run by specifying one or more test lists and/or one or more test containers.
- To run tests using test lists, add MetaDataFile items and associated TestLists here. Paths can
- be server paths or local paths, but server paths relative to the location of this file are highly
- recommended:
- <MetaDataFile Include="$(BuildProjectFolderPath)/HelloWorld/HelloWorld.vsmdi">
- <TestList>BVT1;BVT2</TestList>
- </MetaDataFile>
- To run tests using test containers, add TestContainer items here:
- <TestContainer Include="$(OutDir)\HelloWorldTests.dll" />
- <TestContainer Include="$(SolutionRoot)\TestProject\WebTest1.webtest" />
- <TestContainer Include="$(SolutionRoot)\TestProject\LoadTest1.loadtest" />
- Use %2a instead of * and %3f instead of ? to prevent expansion before test assemblies are built
- -->
- <MetaDataFile Include="$(BuildProjectFolderPath)/http://www.cnblogs.com/Trunk/Product/Sources/RI/StockTraderRI.Tests.AcceptanceTest/StockTraderRI.Tests.AcceptanceTest.vsmdi">
- <TestList>Desktop</TestList>
- </MetaDataFile>
- </ItemGroup>
- <PropertyGroup>
- <!-- TEST ARGUMENTS
- If the RunTest property is set to true, then particular tests within a
- metadata file or test container may be specified here. This is
- equivalent to the /test switch on mstest.exe.
- <TestNames>BVT;HighPriority</TestNames>
- -->
- </PropertyGroup>
- <ItemGroup>
- <!--ADDITIONAL REFERENCE PATH
- The list of additional reference paths to use while resolving references. For example:
- <AdditionalReferencePath Include="C:\MyFolder\" />
- <AdditionalReferencePath Include="C:\MyFolder2\" />
- -->
- </ItemGroup>
- </Project>
MSBuild SideKick是一个查看和修改MSbuild脚本极好的图形化工具(点这里下载), 它可以把比较大又不好读的MSBuild脚本文件按照属性/元组/任务/目标等组织成比较容易阅读和修改的形式, 也可以将整个Build流程图形化. 如果您在团队中的角色是Builder, 那么这个软件毫无疑问应该在您的购买清单中. 我们用MSBuild SideKick工具打开我们的tfbuild.proj, 然后打开图形化显示, 我们就可以看到整个的Team Build 流程(点击图片查看大图):
上图比较形象的表达了整个Team Build的流程, 这个流程以默认的流程定义为基础, 拼合了自定义的流程. 为了加深印象, 我们把这个流程按照时间顺序大体归一下类:
- -> Initialize : 初始化(包括设定生成过程的各种环境变量和属性, 生成BuildNumber)
- -> Clean : 清除中间文件和上一次生成的文件
- -> Get : 获取最新版本
- -> Lable : 给这次生成打上一个标记并记录
- -> Build : 编译生成
- -> Test : 运行各种测试, 比如unit tests文件, 甚至可以直接提供扩展
- -> Packaging : 打包程序集生成安装包
- -> Drop : 将生成的程序集和安装包, 以及log文件, 投递到指定位置
好了,到此为止我们简单讨论了TFS服务器默认的生成流程. 从下一节开始我们可以进行关于最佳实践的讨论了.