【问题标题】:How to ignore Robocopy access denied errors in psake?如何忽略 psake 中的 Robocopy 访问被拒绝错误?
【发布时间】:2016-09-28 15:22:00
【问题描述】:

我正在编写将一个文件夹复制到另一个文件夹的 psake 任务,如下所示。

task -name CopyComponentToBundle -description "Copy the component to bundle" -action {

    Write "Component source is $ComponentPath"
    Write "Component Destination is $ComponentBundlePath"
    exec {      

        Robocopy $ComponentPath $ComponentBundlePath  /MIR /R:0 /W:0
    }   
}

虽然文件夹已成功复制,但我仍然收到如下错误。

在 C:\Program Files\WindowsPowerShell\Modules\psake\psake.psm1:156 char:17 + throw ("Exec:" + $errorMe ssage) +
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [>] 异常:执行:错误 执行命令 Roboc opy $ComponentPath $ComponentBundlePath /MIR /R:0 /W:0 .

有没有办法忽略错误?所有错误都是“访问被拒绝”。

【问题讨论】:

    标签: powershell msbuild robocopy psake


    【解决方案1】:

    您可以尝试在 robocopy 命令之前添加它

    $ErrorActionPreference = 'SilentlyContinue'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-24
      • 2012-12-21
      • 2010-12-23
      • 2017-06-25
      • 1970-01-01
      相关资源
      最近更新 更多