14

I want to include a folder with the build in visual studio. This folder contains my .sqlite file and I need it with my exe file. I was wondering where in visual studio I can select the folders I want to include with the build.

HoBa
  • 3,442
  • 5
  • 26
  • 33

4 Answers4

22
  1. show all file
  2. right click on the file -> include in project enter image description here
  3. right click on the file -> property
  4. set "Copy to output directory" as "Copy Always" enter image description here
bla
  • 5,350
  • 3
  • 25
  • 26
  • 10
    What about complete folders? – Kapé Apr 17 '14 at 12:20
  • 3
    @Kapé, This is sort of hacky, but if you create a new folder then put a placeholder text file in there and set the text file to `content` and `copy always`, it will create the folder. – Charles Clayton Apr 21 '15 at 23:01
  • 1
    [This](http://stackoverflow.com/questions/2059562/in-visual-studio-how-can-i-set-the-build-action-for-an-entire-folder) post shows complete folders – justanotherdev Nov 02 '16 at 02:30
7

While the above answers are correct (and should be marked as so), there may be another scenario where your applications resources may not be static (and therefore cannot be added as resources to the solution). In these cases you can use a post-build command in the project properties window to manually copy files to the output directory..

XCOPY $(SolutionDir)MyDynamicResourcesFolder*.* $(OutputDir)MyDynamicResourcesFolder

MattDavey
  • 8,897
  • 3
  • 31
  • 54
2

A little late but I had the same question but wanted to include an empty directory.

I found this MSDN blog post: http://blogs.msdn.com/b/webdevelopertips/archive/2010/04/29/tip-105-did-you-know-how-to-include-empty-directory-when-package-a-web-application.aspx

By design, Visual Studio 2010 will skip the empty directory when packaging web application project using web deploy. To get empty directory packaged and deployed, we can work around this by adding an empty stub file inside the directory to make it non-empty. Then web deploy will package and deploy the directory with the stub file.

Mike Cheel
  • 12,626
  • 10
  • 72
  • 101
  • I love this mention of using empty stub files; I've been using them to achieve this and similar results, e. g., guaranteeing that a restore creates the directory or it's included in XCOPY tasks, for decades. Frequently, it's even possible to mark the file as hidden or even system without interfering with its intended use. – David A. Gray Jul 22 '18 at 02:57
1

I would say you move your .sqlite file to \yourproject\bin\, or reference it in your project (like someone already explained).

The .sqlite would rather be rear at execution time, not at compile/build time, so including it in the build won't be a solution to your problem.

The right solution should be to include your .sqlite as a resource in your project, so it can access to it an runtime.

Javi Roman
  • 31
  • 2
  • Not sure how to include it as a resource. I'm new doing this kind of builds – HoBa Sep 09 '11 at 08:04
  • This creates extra work if you're working with a repository, as I have just discovered, because /bin/ folders are in .gitignore. – htmlcoderexe Dec 02 '17 at 21:59