【问题标题】:The command "XCOPY" exited with code 4 error while building checkin with new build definition使用新的构建定义构建签入时,命令“XCOPY”退出并出现代码 4 错误
【发布时间】:2013-05-08 12:42:17
【问题描述】:

我正在使用 TFS2012。我已经创建了一个构建定义来构建每个 checkInuding VS2012。在我的项目的 Vs2008 中,我使用 XCOPY 创建了一个预构建事件,以将一些文件从解决方案目录复制到另一个文件夹。但是在我执行 CheckIn Build 之后,由于以下错误而失败

Summary
Debug | Any CPU
 1 error(s), 0 warning(s)
$/test/coding_files/cal_reg.sln - 1 error(s), 0 warning(s), View Log File
 C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets (895): The command "XCOPY "C:\Builds\1\test\New Build Definition 1\Sources\coding_files\*.*" "\\pc97\D\" /E /Y /R /K" exited with code 4.
 $/test/coding_files/cal_reg.sln compiled
 No Test Results
 No Code Coverage Results
Other Errors and Warnings
 1 error(s), 0 warning(s)
 Exception Message: MSBuild error 1 has ended this build. You can find more specific information about the cause of this error in above messages. (type BuildProcessTerminateException)
Exception Stack Trace:    at System.Activities.Statements.Throw.Execute(CodeActivityContext context)
   at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
   at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
   at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

为什么会发生这种情况?如何在构建之前执行复制命令?

【问题讨论】:

  • docs,退出代码4 表示: > 发生初始化错误。没有足够的内存或磁盘 > 空间,或者您在 > 命令行中输入了无效的驱动器名称或无效的语法。
  • 你找到解决这个问题的方法了吗?您能否粘贴您在预构建事件中输入的确切 XCOPY 命令。

标签: visual-studio-2012 build-automation xcopy


【解决方案1】:

请注意,将 /C 开关添加到 xcopy 并不能修复错误。它只是意味着如果 xcopy 遇到一个文件错误并且还有其他文件要复制,它不会导致整个复制过程失败。它只会失败任何无法复制的文件,并继续处理其他可以复制的文件。

在某些情况下,这可能是可取的行为,但也可能很危险,根据您的实现方式隐藏实际的复制问题。

【讨论】:

    【解决方案2】:

    使用start xcopy /Y /R 代替xcopy。这对我有用。

    【讨论】:

    • 这是做什么的?它没有给出输出
    【解决方案3】:

    我通过另一种方式复制解决了这个问题。 使用文本编辑器打开您的 .csproj 文件并修改文件末尾的“AfterBuild”部分:

    <Target Name="AfterBuild">
        <ItemGroup>
            <MyFile Include="myfile.xml"/>
        </ItemGroup>
        <Copy SourceFiles="@(MyFile)" DestinationFolder="$(OutputPath)" />
    </Target>
    

    我从来没有遇到过这种复制方式的问题,它是跨平台的方式

    【讨论】:

    • 你在哪里输入这个 XML?
    【解决方案4】:

    尝试重新启动您的视觉工作室。这可能是暂时的问题。 以下链接将描述不同的方式 Command copy exited with code 4 when building - Visual Studio restart solves it

    【讨论】:

      【解决方案5】:

      在 powershell 中运行相同的 xcopy 命令,我看到了共享 Vilation。添加 /C 到 xcopy 修复了这个问题。

      【讨论】:

        猜你喜欢
        • 2016-06-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-07-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多