Is there a simple way to copy a file in a post-build event for a Visual Studio project, but only if the file exists? (i.e. don't fail the build if the file doesn't exist)
I've tried some options using xcopy. But I feel so stupid - I can't seem to get my head around what switches I might need with xcopy.
Use "IF" command:
IF EXIST file.txt xcopy file.txt [destination_folder]\ /Y
Also without the IF EXIST but using the /U option of XCOPY
xcopy source_file_name dest_folder /u /y
来源:https://stackoverflow.com/questions/11422555/vs-postbuild-event-copy-file-if-it-exists