简体   繁体   中英

Visual Studio C++ project management. How do I handle non-code files in a project?

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.

您可以使用构建前事件来创建目录并复制文件。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM