gpt4 book ai didi

c# - TFS 构建 CopyDirectory 错误不停止构建

转载 作者:行者123 更新时间:2023-11-30 15:32:35 26 4
gpt4 key购买 nike

我的构建模板中有一个 CopyDirectory 步骤,我假设如果它找到一个不存在的目录,它会抛出错误。但是,它只是发出警告,并且构建本身被标记为成功。

我尝试将它包裹在 try/catch block 中,并手动执行“抛出”异常步骤,但仍然无效。我试图将 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 &amp; &quot;\_PublishedWebsites\&quot; &amp; SCWebOutputFolder]" />
<mtbwa:WriteBuildMessage sap2010:WorkflowViewState.IdRef="WriteBuildMessage_16" Importance="[Microsoft.TeamFoundation.Build.Client.BuildMessageImportance.High]" Message="[&quot;Code Files copied to &quot; &amp; 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 &amp; &quot;\_PublishedWebsites\&quot; &amp; SCConfigSourceFolder &amp; &quot;\&quot; &amp; SCCDServerRole]" />
<mtbwa:WriteBuildMessage sap2010:WorkflowViewState.IdRef="WriteBuildMessage_17" Importance="[Microsoft.TeamFoundation.Build.Client.BuildMessageImportance.High]" Message="[&quot;Config Files copied to &quot; &amp; server &amp; Environment.NewLine &amp; &quot;Copied from: &quot; &amp; BuildDetail.DropLocation &amp; &quot;\_PublishedWebsites\&quot; &amp; SCConfigSourceFolder &amp; &quot;\&quot; &amp; 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 &amp; &quot;\_PublishedWebsites\&quot; &amp; SCSitecoreFilesSourceFolder]" />
<mtbwa:WriteBuildMessage sap2010:WorkflowViewState.IdRef="WriteBuildMessage_18" Importance="[Microsoft.TeamFoundation.Build.Client.BuildMessageImportance.High]" Message="[&quot;Sitecore Files copied to &quot; &amp; server &amp; Environment.NewLine &amp; &quot;Copied from: &quot; &amp; BuildDetail.DropLocation &amp; &quot;\_PublishedWebsites\&quot; &amp; SCSitecoreFilesSourceFolder]" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces" />
</Sequence>
</ActivityAction>
</ForEach>

最佳答案

CopyDirectory 确实有一个错误,它只会在源目录不存在时发出警告。它还存在长路径问题(>248 个字符)。

可能的解决方法:

  1. 使用InvokeCommand,运行Robocopy.exe(优于xcopy)并检查其结果代码。
  2. 如果您必须使用 CopyDirectory,请自行检查源目录是否存在。

关于c# - TFS 构建 CopyDirectory 错误不停止构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18796008/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com