我是从TFS开始的,我想自定义我的构建顺序。 首先,我试图学习默认模板。 我无法弄清楚这2个MSBuild调用之间有什么区别。
<If Condition="[CleanWorkspace = Microsoft.TeamFoundation.Build.Workflow.Activities.CleanWorkspaceOption.Outputs]" DisplayName="If CleanWorkspace = CleanWorkspaceOption.Outputs" mtbwt:BuildTrackingParticipant.Importance="Low">
<If.Then>
<ForEach x:TypeArguments="mtbwa:PlatformConfiguration" DisplayName="For Each Configuration in BuildSettings.PlatformConfigurations" Values="[BuildSettings.PlatformConfigurations]" mtbwt:BuildTrackingParticipant.Importance="Low">
<ActivityAction x:TypeArguments="mtbwa:PlatformConfiguration">
<ActivityAction.Argument>
<DelegateInArgument x:TypeArguments="mtbwa:PlatformConfiguration" Name="platformConfiguration" />
</ActivityAction.Argument>
<Sequence DisplayName="Clean Configuration">
<If Condition="[BuildSettings.HasProjectsToBuild]" DisplayName="If BuildSettings.HasProjectsToBuild" mtbwt:BuildTrackingParticipant.Importance="Low">
<If.Then>
<ForEach x:TypeArguments="x:String" DisplayName="For Each Project in BuildSettings.ProjectsToBuild" Values="[BuildSettings.ProjectsToBuild]" mtbwt:BuildTrackingParticipant.Importance="Low">
<ActivityAction x:TypeArguments="x:String">
<ActivityAction.Argument>
<DelegateInArgument x:TypeArguments="x:String" Name="serverBuildProjectItem" />
</ActivityAction.Argument>
<Sequence DisplayName="Clean Project" mtbwt:BuildTrackingParticipant.Importance="Low">
<Sequence.Variables>
<Variable x:TypeArguments="x:String" Name="localBuildProjectItem" />
</Sequence.Variables>
<mtbwa:ConvertWorkspaceItem DisplayName="Convert Server Paths to Local Paths" Input="[serverBuildProjectItem]" Result="[localBuildProjectItem]" Workspace="[Workspace]" mtbwt:BuildTrackingParticipant.Importance="Low" />
<If Condition="[System.IO.File.Exists(localBuildProjectItem)]" DisplayName="If File.Exists(Project)" mtbwt:BuildTrackingParticipant.Importance="Low">
<If.Then>
<mtbwa:MSBuild CommandLineArguments="[String.Format("/p:SkipInvalidConfigurations=true {0}", MSBuildArguments)]" Configuration="[platformConfiguration.Configuration]" DisplayName="Run MSBuild for Project" GenerateVSPropsFile="[True]" MaxProcesses="[If (MSBuildMultiProc, 0, 1)]" OutDir="[BinariesDirectory]" Platform="[platformConfiguration.Platform]" Project="[localBuildProjectItem]" Targets="[New String() { "Clean" }]" TargetsNotLogged="[New String() {"GetNativeManifest", "GetCopyToOutputDirectoryItems", "GetTargetPath"}]" ToolPlatform="[MSBuildPlatform]" Verbosity="[Verbosity]" />
</If.Then>
</If>
</Sequence>
</ActivityAction>
</ForEach>
</If.Then>
</If>
</Sequence>
</ActivityAction>
</ForEach>
</If.Then>
</If>
<mtbwa:SyncWorkspace DisplayName="Get Workspace" VersionOverride="[GetVersion]" Workspace="[Workspace]">
<mtbwa:SyncWorkspace.RequestsFailed>
<ActivityAction x:TypeArguments="scg:ICollection(mtbc:IQueuedBuild)">
<ActivityAction.Argument>
<DelegateInArgument x:TypeArguments="scg:ICollection(mtbc:IQueuedBuild)" Name="failedRequests" />
</ActivityAction.Argument>
<mtbwa:RetryRequests Behavior="[Microsoft.TeamFoundation.Build.Workflow.Activities.RetryBehavior.DoNotBatch]" DisplayName="Mark Requests for Retry" Requests="[failedRequests]" mtbwt:BuildTrackingParticipant.Importance="Low" />
</ActivityAction>
</mtbwa:SyncWorkspace.RequestsFailed>
</mtbwa:SyncWorkspace>
</Sequence>
<If Condition="[CreateLabel]" DisplayName="If CreateLabel" mtbwt:BuildTrackingParticipant.Importance="Low">
<If.Then>
<mtbwa:InvokeForReason DisplayName="Create and Set Label for non-Shelveset Builds" Reason="Manual, IndividualCI, BatchedCI, Schedule, ScheduleForced, UserCreated">
<mtbwa:LabelWorkspace Comment="["Label Created by Team Build"]" DisplayName="Create Label" Name="[LabelName]" Scope="[String.Format("$/{0}", BuildDetail.BuildDefinition.TeamProject)]" Workspace="[Workspace]" />
<mtbwa:SetBuildProperties DisplayName="Set Label on BuildDetail" LabelName="[String.Format("{0}@$/{1}", LabelName, BuildDetail.BuildDefinition.TeamProject)]" PropertiesToSet="LabelName" mtbwt:BuildTrackingParticipant.Importance="Low" />
</mtbwa:InvokeForReason>
</If.Then>
<If.Else>
<mtbwa:WriteBuildMessage DisplayName="Write Message" Message="Not Labeling sources" Importance="[Microsoft.TeamFoundation.Build.Client.BuildMessageImportance.High]" />
</If.Else>
</If>
<TryCatch DisplayName="Try Compile, Test, and Associate Changesets and Work Items" mtbwt:BuildTrackingParticipant.Importance="Low">
<TryCatch.Finally>
<Sequence DisplayName="Revert Workspace and Copy Files to Drop Location" mtbwt:BuildTrackingParticipant.Importance="Low">
<mtbwa:InvokeForReason DisplayName="Revert Workspace for Shelveset Builds" Reason="CheckInShelveset, ValidateShelveset">
<mtbwa:RevertWorkspace DisplayName="Revert Workspace" Workspace="[Workspace]" />
</mtbwa:InvokeForReason>
<If Condition="[Not String.IsNullOrEmpty(DropLocation)]" DisplayName="If DropLocation is Set" mtbwt:BuildTrackingParticipant.Importance="Low">
<If.Then>
<mtbwa:CopyDirectory DisplayName="Drop Files to Drop Location" Source="[BinariesDirectory]" Destination="[DropLocation]" />
</If.Then>
</If>
</Sequence>
</TryCatch.Finally>
<TryCatch.Try>
<Sequence mtbwt:BuildTrackingParticipant.Importance="None">
<Sequence.Variables>
<Variable x:TypeArguments="s:Exception" Name="compilationException" />
<Variable x:TypeArguments="scg:IList(mtvc:Changeset)" Name="associatedChangesets" />
<Variable x:TypeArguments="s:Boolean" Name="treatTestFailureAsBuildFailure" />
</Sequence.Variables>
<Parallel DisplayName="Compile, Test, and Associate Changesets and Work Items">
<TryCatch DisplayName="Try Compile and Test" mtbwt:BuildTrackingParticipant.Importance="Low">
<TryCatch.Try>
<Sequence DisplayName="Compile and Test">
<ForEach x:TypeArguments="mtbwa:PlatformConfiguration" DisplayName="For Each Configuration in BuildSettings.PlatformConfigurations" Values="[BuildSettings.PlatformConfigurations]" mtbwt:BuildTrackingParticipant.Importance="Low">
<ActivityAction x:TypeArguments="mtbwa:PlatformConfiguration">
<ActivityAction.Argument>
<DelegateInArgument x:TypeArguments="mtbwa:PlatformConfiguration" Name="platformConfiguration" />
</ActivityAction.Argument>
<Sequence DisplayName="Compile and Test for Configuration" mtbwt:BuildTrackingParticipant.Importance="Low">
<Sequence.Variables>
<Variable x:TypeArguments="x:String" Name="outputDirectory" />
<Variable x:TypeArguments="x:String" Name="logFileDropLocation" />
</Sequence.Variables>
<Sequence DisplayName="Initialize Variables" mtbwt:BuildTrackingParticipant.Importance="Low">
<Assign x:TypeArguments="x:String" DisplayName="Create OutputDirectory Per Platform and Configuration" To="[outputDirectory]" Value="[If (platformConfiguration.IsEmpty Or BuildSettings.PlatformConfigurations.Count = 1, BinariesDirectory, If (platformConfiguration.IsPlatformEmptyOrAnyCpu, BinariesDirectory + "\" + platformConfiguration.Configuration, BinariesDirectory + "\" + platformConfiguration.Platform + "\" + platformConfiguration.Configuration))]" mtbwt:BuildTrackingParticipant.Importance="Low" />
<If Condition="[Not String.IsNullOrEmpty(DropLocation)]" DisplayName="If DropLocation is Set" mtbwt:BuildTrackingParticipant.Importance="Low">
<If.Then>
<Assign x:TypeArguments="x:String" DisplayName="Initialize LogFile Drop Location" To="[logFileDropLocation]" Value="[If (platformConfiguration.IsEmpty Or BuildSettings.PlatformConfigurations.Count = 1, BuildDropProvider.CombinePaths(DropLocation, "logs"), If (platformConfiguration.IsPlatformEmptyOrAnyCpu, BuildDropProvider.CombinePaths(DropLocation, "logs", platformConfiguration.Configuration), BuildDropProvider.CombinePaths(DropLocation, "logs", platformConfiguration.Platform, platformConfiguration.Configuration)))]" mtbwt:BuildTrackingParticipant.Importance="Low" />
</If.Then>
</If>
</Sequence>
<If Condition="[BuildSettings.HasProjectsToBuild]" DisplayName="If BuildSettings.HasProjectsToBuild" mtbwt:BuildTrackingParticipant.Importance="Low">
<If.Then>
<ForEach x:TypeArguments="x:String" DisplayName="For Each Project in BuildSettings.ProjectsToBuild" Values="[BuildSettings.ProjectsToBuild]" mtbwt:BuildTrackingParticipant.Importance="Low">
<ActivityAction x:TypeArguments="x:String">
<ActivityAction.Argument>
<DelegateInArgument x:TypeArguments="x:String" Name="serverBuildProjectItem" />
</ActivityAction.Argument>
<TryCatch DisplayName="Try to Compile the Project" mtbwt:BuildTrackingParticipant.Importance="Low">
<TryCatch.Try>
<Sequence DisplayName="Compile the Project" mtbwt:BuildTrackingParticipant.Importance="Low">
<Sequence.Variables>
<Variable x:TypeArguments="x:String" Name="localProject" />
<Variable x:TypeArguments="x:String" Name="outputDirectoryPerProject" Default="[outputDirectory]" />
</Sequence.Variables>
<mtbwa:ConvertWorkspaceItem DisplayName="Convert Server Path to Local Path" Input="[serverBuildProjectItem]" Result="[localProject]" Workspace="[Workspace]" mtbwt:BuildTrackingParticipant.Importance="Low" />
<If Condition="[SolutionSpecificBuildOutputs]" DisplayName="If Build Outputs are Solution-Specific" mtbwt:BuildTrackingParticipant.Importance="Low">
<If.Then>
<Sequence DisplayName="Update Output Directory" mtbwt:BuildTrackingParticipant.Importance="Low">
<Assign x:TypeArguments="x:String" DisplayName="Set Solution-Specific Output Directory" To="[outputDirectoryPerProject]" Value="[System.IO.Path.Combine(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(localProject))]" mtbwt:BuildTrackingParticipant.Importance="Low" />
<If DisplayName="If Output Directory Exists" Condition="[System.IO.Directory.Exists(outputDirectoryPerProject)]" mtbwt:BuildTrackingParticipant.Importance="Low">
<If.Then>
<mtbwa:WriteBuildWarning DisplayName="Write Duplicate Project Names Warning" Message="[String.Format("{0} conflicts with another solution/project. Build outputs for solutions/projects with the same name will be copied to the same directory. To separate the build outputs, change the name of one of the solutions/projects.", System.IO.Path.GetFileNameWithoutExtension(localProject))]" />
</If.Then>
</If>
</Sequence>
</If.Then>
</If>
<mtbwa:MSBuild CommandLineArguments="[String.Format("/p:SkipInvalidConfigurations=true {0}", MSBuildArguments)]" Configuration="[platformConfiguration.Configuration]" DisplayName="Run MSBuild for Project" GenerateVSPropsFile="[True]" LogFileDropLocation="[logFileDropLocation]" MaxProcesses="[If (MSBuildMultiProc, 0, 1)]" OutDir="[outputDirectoryPerProject]" Platform="[platformConfiguration.Platform]" Project="[localProject]" RunCodeAnalysis="[RunCodeAnalysis]" TargetsNotLogged="[New String() {"GetNativeManifest", "GetCopyToOutputDirectoryItems", "GetTargetPath"}]" ToolPlatform="[MSBuildPlatform]" Verbosity="[Verbosity]" />
</Sequence>
</TryCatch.Try>
<TryCatch.Catches>
<Catch x:TypeArguments="s:Exception">
<ActivityAction x:TypeArguments="s:Exception">
<ActivityAction.Argument>
<DelegateInArgument x:TypeArguments="s:Exception" Name="ex" />
</ActivityAction.Argument>
<Sequence DisplayName="Handle Exception">
<Sequence.Variables>
<Variable x:TypeArguments="scg:ICollection(mtbc:IQueuedBuild)" Name="failedRequests" />
</Sequence.Variables>
<mtbwa:SetBuildProperties CompilationStatus="[Microsoft.TeamFoundation.Build.Client.BuildPhaseStatus.Failed]" DisplayName="Set CompilationStatus to Failed" PropertiesToSet="CompilationStatus" mtbwt:BuildTrackingParticipant.Importance="Low" />
<If Condition="[CreateWorkItem]" DisplayName="If CreateWorkItem" mtbwt:BuildTrackingParticipant.Importance="Low">
<If.Then>
<mtbwa:InvokeForReason DisplayName="Create Work Item for non-Shelveset Builds" Reason="Manual, IndividualCI, BatchedCI, Schedule, ScheduleForced, UserCreated">
<mtbwa:OpenWorkItem AssignedTo="[BuildDetail.RequestedFor]" Comment="["This work item was created by TFS Build on a build failure."]" CustomFields="[New Dictionary(Of String, String) From { {"System.Reason", "Build Failure"}, {"Microsoft.VSTS.TCM.ReproSteps", "Start the build using TFS Build"}, {"Priority", "1"}, {"Severity", "1 - Critical"} }]" DisplayName="Create Work Item" Title="[String.Format("Build Failure in Build: {0}", BuildDetail.BuildNumber)]" Type="["Bug"]" />
</mtbwa:InvokeForReason>
</If.Then>
</If>
<mtbwa:GetApprovedRequests DisplayName="Get Requests Approved for Check In" Result="[failedRequests]" mtbwt:BuildTrackingParticipant.Importance="None" />
<mtbwa:RetryRequests Behavior="[Microsoft.TeamFoundation.Build.Workflow.Activities.RetryBehavior.DoNotBatch]" DisplayName="Mark Requests for Retry" Requests="[failedRequests]" mtbwt:BuildTrackingParticipant.Importance="Low" />
<Rethrow DisplayName="Rethrow the exception so the build will stop" mtbwt:BuildTrackingParticipant.Importance="Low" />
</Sequence>
</ActivityAction>
</Catch>
</TryCatch.Catches>
</TryCatch>
</ActivityAction>
</ForEach>
</If.Then>
</If>
(此ofcource是XML的一部分)
提前致谢!
答案 0 :(得分:0)
不同之处在于二进制文件的输出位置。第一个是当您使用Output location = SingleFolder
设置构建标准时,它使用OutDir="[BinariesDirectory]"
调用MSBuild,它将所有二进制文件复制到同一目录。
第二个是Output location = PerProject
,它将每个项目二进制文件复制到它们自己的子文件夹中。