我有以下post build命令:
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
错误是什么?
答案 0 :(得分: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