【问题标题】:Post-Build Event VS 2010 "Fails", but really doesn't构建后事件 VS 2010 “失败”,但实际上并没有
【发布时间】:2012-07-05 21:46:39
【问题描述】:

我在 VS 2010 中发生了一个相对简单的构建后事件,只有两个复制操作。

复制操作的输出显示它们已经成功,并且我检查了目录并且文件复制工作正常。

VS 告诉我构建失败,但没有告诉我原因...这是确切的输出:

1>PostBuildEvent:
1>  Description: Copying Library to Animation-Calibrator
1>          1 file(s) copied.
1>  
1>  -------------------------------------------------------------------------------
1>     ROBOCOPY     ::     Robust File Copy for Windows                              
1>  -------------------------------------------------------------------------------
1>  
1>    Started : Thu Jul 05 14:26:34 2012
1>  
1>     Source : C:\Users\Tag\Google Drive\Projects\TGAEngine\VS2010\obj\
1>       Dest : C:\Users\Tag\Google Drive\Projects\Animation-Calibrator\lib\TGAEngine\obj\
1>  
1>      Files : *.*
1>          
1>    Options : *.* /S /COPY:DAT /R:1000000 /W:30 
1>  
1>  ------------------------------------------------------------------------------
... List of files copied, no errors
1>  
1>  ------------------------------------------------------------------------------
1>  
1>                 Total    Copied   Skipped  Mismatch    FAILED    Extras
1>      Dirs :         2         0         2         0         0         0
1>     Files :        29        29         0         0         0         1
1>     Bytes :    1.92 m    1.92 m         0         0         0       697
1>     Times :   0:00:00   0:00:00                       0:00:00   0:00:00
1>  
1>  
1>     Speed :           100824150 Bytes/sec.
1>     Speed :            5769.204 MegaBytes/min.
1>  
1>     Ended : Thu Jul 05 14:26:34 2012
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: The command "copy /y .\TGAEngine.lib .\..\..\Animation-Calibrator\lib\TGAEngine
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: robocopy /s ".\obj" ".\..\..\Animation-Calibrator\lib\TGAEngine\obj"
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5): error MSB3073: :VCEnd" exited with code 3.
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.11
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

我已将范围缩小到 robocopy 命令。
如果我这样做 robocopy /s source dest VS 失败。
如果我不使用参数“/s”,它不会失败,但不会复制文件。

有什么想法吗?

我只是不发布脚本,因为我是手动运行的,没有任何错误。

【问题讨论】:

    标签: visual-studio-2010 post-build-event


    【解决方案1】:

    通常,如果进程成功,则返回exit status 0,如果失败则返回非零。 robocopy 似乎有一个不标准的exit code definition:1 也表示成功; 0 意味着没有文件被复制。你现在明白为什么省略/s VS 不会抱怨了吗?

    您的进程似乎以状态 3 退出。如果这符合您的要求,请查看 robocopy 的文档。据我了解,任何 2 或更大的值都意味着麻烦。

    你应该自己检查退出代码,如果它指示错误情况,如果一切正常,则以0退出(下面的代码未经测试):

    if ERRORLEVEL 2 goto HandleError
    exit 0
    :HandleError
    exit %ERRORLEVEL%
    

    【讨论】:

      【解决方案2】:

      我找到了这个here

      (robocopy /s source dest) ^& IF %ERRORLEVEL% LEQ 3 exit 0
      

      这是 krlmlr 答案的较短版本,可以在单个命令行中运行。我认为错误级别 3 或以下的错误与复制文件时的退出代码一样成功(退出代码 1)并且目标中有额外文件(退出代码 2)。

      【讨论】:

        猜你喜欢
        • 2014-07-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-10-28
        • 1970-01-01
        • 2022-01-11
        相关资源
        最近更新 更多