简体   繁体   English

Visual Studio C ++项目管理。 如何处理项目中的非代码文件?

[英]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.

相关问题 如何在 Visual Studio 中打开 C++ 项目文件夹? - How do I open a c++ project folder in visual studio? 如何在 Visual Studio 中编辑 c++ 项目的源文件? - How do I edit the source files of a c++ project in Visual Studio? 如何在Visual Studio 2010中的C ++ googletest项目中设置代码覆盖率 - How do I set up code coverage in C++ googletest project in Visual Studio 2010 如何将扩展链接到Project(Visual Studio C ++) - How do I link Extensions to Project (Visual Studio C++ ) 如何从 Visual Studio 项目中读取 C++ 中的 netcdf 文件? - How do i read netcdf files in c++ from a visual studio project? 如何在 Visual Studio 项目中“单独”运行 C++ 文件而不受其他文件的影响? - How do I run a C++ file “by itself” in a Visual Studio project without the influence of other files? 如何使Visual Studio 2015 C ++项目与Visual Studio 2010兼容? - How do I make a Visual Studio 2015 C++ project compatible with Visual Studio 2010? 如何在 Visual Studio Code 的 C++ 项目中使用外部库 - How to use external libraries in a C++ project in Visual Studio Code 拆分一个Visual Studio C ++项目:如何(几乎)自动做到? - Split a Visual Studio C++ project : how to do it (almost) automatically? 您如何打包要发布的 Visual Studio C++ 项目? - How do you pack a visual studio c++ project for release?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM