开发者

Copy files during build

开发者 https://www.devze.com 2023-02-05 05:23 出处:网络
I have some text files that my program needs to load. The program will look for these files in the executable directory. Currently these files files reside in the project directory (and are part of th

I have some text files that my program needs to load. The program will look for these files in the executable directory. Currently these files files reside in the project directory (and are part of the project).

Is there a way to tell visual studio to put these files in the bin/debug (or bin/release) directory as part of t开发者_Python百科he building process?


As Conrad Frix explained, build events is one solution.

However, if you do not want to mess around with CMD macros, you might want to simply add the text files to your project:

  1. For every text file, open its properties (right-click in the Solution Explorer and select Properties).
  2. In the Build Action property, specify Content.
  3. In the Copy to Output Directory property, either select Copy Always or Copy if Newer.

If you generate setup projects in Visual Studio, and you want to include the text files, you can then simply add the Content files of the given project and the build process will package them along with your executable.


Try using build events

You can use $(TargetDir) macro which will go to bin/release or bin/debug depending on which you are doing. Here's the compete list of macros

for example Copy "$(ProjectDir)*.txt" "$(TargetDir)"

would copy all the txt files from your project directory to the target directory


Sure. Use a post-build event, configured in the project properties window.

0

精彩评论

暂无评论...
验证码 换一张
取 消