Visual Studio后构建xcopy不起作用:错误MSB3073:“VCEnd”以代码4退出

3

我有以下的后构建命令:

XCOPY "$(SolutionDir)*" "D:\VS\Win1\*" /EXCLUDE:"E:\exclude.txt" /Y /E /D

构建时,我收到以下信息:

1>------ Build started: Project: Win1, Configuration: Debug Win32 ------
1>  Can't read file: "E:\exclude.txt"
1>  
1>  0 File(s) copied
1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5):
    error MSB3073: The command "XCOPY "C:\Users\Administrator\Desktop\Win1\*" 
    "D:\VS\Win1\*" /EXCLUDE:"E:\exclude.txt" /Y /E /D
1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(113,5):
     error MSB3073: :VCEnd" exited with code 4.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

E:\exclude.txt 文件内容:

.sdf

\Debug\

\ipch\

\Trash\

我不知道为什么会出现这个错误。VS提示无法读取文件:"E:\exclude.txt",但我检查过文件是存在的。我也看了SO上的其他帖子,但没有发现有相同的问题。你知道如何解决吗?

编辑:

xcopy 成功复制文件,感谢 @RustyX 的回答。但它还是给出了错误代码 1:

1>------ Build started: Project: Win1, Configuration: Debug Win32 ------
1>  tkk.cpp
1>  Win1.vcxproj -> D:\T\Win1\Win1.exe
1>  C:\Users\Administrator\Desktop\Win1\Source\tkk.h
1>  1 File(s) copied
1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(112,5):
    error MSB3073: The command "XCOPY "C:\Users\Administrator\Desktop\Win1\*"
    "D:\VS\Win1\*" /EXCLUDE:E:\exclude.txt /Y /E /D
1>C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets(112,5): 
    error MSB3073: echo f | XCOPY "C:\Users\Administrator\Desktop\Win1\Debug\Win1.pch" 
    "D:\VS\Win1\Debug\Win1.pch" /Y /E /F /D" exited with code 1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

当我在 cmd 窗口中运行该命令时,它会显示:0 个文件已复制
XCOPY "C:\Users\Administrator\Desktop\Win1\*"
    "D:\VS\Win1\*" /EXCLUDE:E:\exclude.txt /Y /E /D

并且:

echo f | XCOPY "C:\Users\Administrator\Desktop\Win1\Debug\Win1.pch" 
    "D:\VS\Win1\Debug\Win1.pch" /Y /E /F /D

错误是什么?


请在输出窗口查看XCopy生成的错误消息。 - Hans Passant
@HansPassant,“xcopy”成功复制了文件,但仍然给出了错误代码1,请参见我的编辑。 - Thanh Nguyen
1个回答

1
您的XCOPY命令无效。如果在命令提示符中运行它,您会发现它无法工作:
> XCOPY "C:\Users\Administrator\Desktop\Win1\*" "D:\VS\Win1\*" /EXCLUDE:"E:\exclude.txt" /Y /E /D
Can't read file: "E:\exclude.txt"

尝试在/EXCLUDE:之后删除引号。
XCOPY "$(SolutionDir)*" "D:\VS\Win1\*" /EXCLUDE:E:\exclude.txt /Y /E /D

您的命令出现了错误:VCEnd以代码1退出,尽管项目已经构建并且文件已经成功复制。您知道为什么吗? - Thanh Nguyen
2
当运行 XCOPY "C:\Users\Administrator\Desktop\Win1\*" "D:\VS\Win1\*" /EXCLUDE:"E:\exclude.txt" /Y /E /D 时,它成功了,但是当运行 XCOPY "C:\Users\Administrator\Desktop\Win1\*" "D:\VS\Win1\*" /EXCLUDE:"E:\exclude.txt" /Y /E /D :VCEnd 时,它失败了。我不知道为什么 VS 添加了 :VCEnd 到我的命令中。 - Thanh Nguyen

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接