Visual Studio C++ 项目管理。 如何处理项目中的非代码文件?
我有一个 C++ 解决方案项目。 对于该项目,我有一些想要在项目内管理的配置文件,当我构建项目时,将这些配置文件添加到正确目录结构中的可执行构建路径中。
示例:
test.exe 引用 config/myconfig.txt
有没有办法设置 myconfig.txt 和我的项目,以便当我构建 test.exe 时,我得到
/
以及
//config/config.txt
因此,当我运行测试时,所有路径都保持正确的顺序,而无需我进入并手动创建这些目录。
我不确定我在这里是否有意义,但也许你们中的一个人会明白我要去哪里。
I have a project in a c++ solution. 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
Is there a way to setup myconfig.txt and my project so when I build test.exe, I get
/
as well as
//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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用预构建事件来创建目录并复制文件。
You could use pre-build events to create the directories and copy the files.
在 Visual Studio 的解决方案资源管理器中,您可以右键单击非代码文件,选择“属性”并设置“复制到输出目录”属性。
这会在构建文件中创建一条规则,以 (1) 包含该文件,以及 (2) 在构建过程中复制该文件。 换句话说,无需 Visual Studio 也可以实现此行为,但需要多做一些工作。
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.
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. In other words, it's possible to get this behavior without Visual Studio, but a little more work.