我的构建模板中有一个CopyDirectory步骤,我假设如果找到一个不存在的目录,它会抛出错误。但是,它只是发出警告,并且构建本身标记为成功。
我试图将它包装在try / catch块中,并手动执行'throw'异常步骤,但仍然无法正常工作。我试图将buildStatus设置为失败,但这也不起作用。我可以用另一种方式实现这个目标吗如果任何复制目录失败,我不希望构建成功。
编辑:
以下是复制目录所在的片段。我正在遍历服务器列表并复制一堆目录。
<ForEach x:TypeArguments="x:String" sap2010:WorkflowViewState.IdRef="ForEach`1_4" Values="[SCCDServers]">
<ActivityAction x:TypeArguments="x:String">
<ActivityAction.Argument>
<DelegateInArgument x:TypeArguments="x:String" Name="server" />
</ActivityAction.Argument>
<Sequence sap2010:WorkflowViewState.IdRef="Sequence_37">
<mtbwa:CopyDirectory Destination="[server]" DisplayName="Copy Code Files" sap2010:WorkflowViewState.IdRef="CopyDirectory_14" Source="[BuildDetail.DropLocation & "\_PublishedWebsites\" & SCWebOutputFolder]" />
<mtbwa:WriteBuildMessage sap2010:WorkflowViewState.IdRef="WriteBuildMessage_16" Importance="[Microsoft.TeamFoundation.Build.Client.BuildMessageImportance.High]" Message="["Code Files copied to " & server]" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces" />
<mtbwa:CopyDirectory Destination="[server]" DisplayName="Copy Config Files" sap2010:WorkflowViewState.IdRef="CopyDirectory_15" Source="[BuildDetail.DropLocation & "\_PublishedWebsites\" & SCConfigSourceFolder & "\" & SCCDServerRole]" />
<mtbwa:WriteBuildMessage sap2010:WorkflowViewState.IdRef="WriteBuildMessage_17" Importance="[Microsoft.TeamFoundation.Build.Client.BuildMessageImportance.High]" Message="["Config Files copied to " & server & Environment.NewLine & "Copied from: " & BuildDetail.DropLocation & "\_PublishedWebsites\" & SCConfigSourceFolder & "\" & SCCDServerRole]" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces" />
<mtbwa:CopyDirectory Destination="[server]" DisplayName="Copy Sitecore Files" sap2010:WorkflowViewState.IdRef="CopyDirectory_16" Source="[BuildDetail.DropLocation & "\_PublishedWebsites\" & SCSitecoreFilesSourceFolder]" />
<mtbwa:WriteBuildMessage sap2010:WorkflowViewState.IdRef="WriteBuildMessage_18" Importance="[Microsoft.TeamFoundation.Build.Client.BuildMessageImportance.High]" Message="["Sitecore Files copied to " & server & Environment.NewLine & "Copied from: " & BuildDetail.DropLocation & "\_PublishedWebsites\" & SCSitecoreFilesSourceFolder]" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces" />
</Sequence>
</ActivityAction>
</ForEach>
答案 0 :(得分:2)
为什么不使用“InvokeProcess”活动?
答案 1 :(得分:2)
CopyDirectory
确实有一个只在源目录不存在时发出警告的错误。它也存在长路径(> 248个字符)的问题。
可能的解决方法:
InvokeCommand
,运行Robocopy.exe
(优于xcopy
)并检查其结果代码。CopyDirectory
,请检查源目录是否存在。答案 2 :(得分:0)
如果复制失败,请在自定义工作流程中将setbuildproperties状态设置为失败。
<mtbwa1:SetBuildProperties DisplayName=“Set build status failed“ PropertiesToSet=“Status“ Status=“[Microsoft.TeamFoundation.Build.Client.BuildStatus.Failed]“ />
http://msdn.microsoft.com/en-us/library/bb399143(v=vs.100).aspx