VS工程“生成事件”之文件拷贝
清泛原创
有时工程下面引用了lib文件,但是编译Debug/Release等版本时需要将dll拷至指定目录才能运行,
如果有多个编译版本需要拷贝多份,这样不便于维护(config等配置文件也是如此,最好不要弄多份副本)。这时我们“在生成事件”中拷贝文件就能解决这个问题,如“预先生成事件”在编译前执行:

拷单文件至Debug/Release目录(支持*通配符):
copy "$(ProjectDir)lib\P*APID.dll" "$(SolutionDir)$(ConfigurationName)\"
拷文件夹:
xcopy /D /Y /E "$(ProjectDir)conf" "$(SolutionDir)$(ConfigurationName)\conf\"
(/D 只复制时间戳最新的文件,/Y 不提示覆盖,/E 递归子目录)
实际上就是执行copy、xcopy等Dos命令,具体用法可参照Dos帮助。$(SolutionDir)等宏命令可参考:


上一篇:std::vector find查找方法
下一篇:xtree(1796): warning C4800: “int”: 将值强制为布尔值“true”或“false”(性能警告)