[英]Visual Studio C++ project management. How do I handle non-code files in a project?
I have a project in a c++ solution. 我在C ++解决方案中有一个项目。 For that project, I have some config files that I would like to manage from within the project and when I build the project, have those config files added to the executable build path in the proper directory structure. 对于那个项目,我有一些配置文件,我想从项目内部进行管理,并且在我构建项目时,将那些配置文件以适当的目录结构添加到可执行文件的构建路径中。
Example: 例:
test.exe references config/myconfig.txt test.exe引用config / myconfig.txt
Is there a way to setup myconfig.txt and my project so when I build test.exe, I get 有没有办法设置myconfig.txt和我的项目,所以当我构建test.exe时,我得到了
/ /
as well as 以及
//config/config.txt //config/config.txt
so when I run test, all paths stay in the proper order without me having to go in and manually create those directories. 因此,当我运行测试时,所有路径都将保持正确的顺序,而无需我亲自进入并手动创建这些目录。
I'm not sure I'm making sense here, but maybe one of you will understand where I'm going. 我不确定我在这里是否有意义,但也许你们中的一个会明白我要去的地方。
您可以使用构建前事件来创建目录并复制文件。
In Visual Studio's Solution Explorer, you can right-click on the non-code files, select "Properties" and set the "Copy To Output Directory" property. 在Visual Studio的解决方案资源管理器中,可以右键单击非代码文件,选择“属性”,然后设置“复制到输出目录”属性。
This creates a rule in the build file to (1) include the file, and (2) to copy that file as part of the build process. 这将在构建文件中创建一个规则,以(1)包含该文件,并(2)在构建过程中复制该文件。 In other words, it's possible to get this behavior without Visual Studio, but a little more work. 换句话说,可以在没有Visual Studio的情况下获得此行为,但需要做更多的工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.