且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使Visual Studio将DLL文件复制到输出目录?

更新时间:2022-10-20 19:04:04

在项目中使用后构建操作,并添加命令以复制违规DLL。 post-build操作是作为批处理脚本编写的。



输出目录可以被引用为 $(OutDir)。项目目录可以作为 $(ProjDir)。尝试在适用的情况下使用相对的贴图,以便您可以复制或移动项目文件夹,而不会影响后期制作。


I have a Visual Studio C++ project that relies on an external DLL file. How can I make Visual Studio copy this DLL file automatically into the output directory (debug/release) when I build the project?

Use a post-build action in your project, and add the commands to copy the offending DLL. The post-build action are written as a batch script.

The output directory can be referenced as $(OutDir). The project directory is available as $(ProjDir). Try to use relative pathes where applicable, so that you can copy or move your project folder without breaking the post-build action.