Author Topic: Adding a data folder to my .NET project to be included with build  (Read 2031 times)

0 Members and 1 Guest are viewing this topic.

Atook

  • Swamp Rat
  • Posts: 1027
  • AKA Tim
Adding a data folder to my .NET project to be included with build
« on: September 12, 2018, 04:53:42 PM »
Hey gang.

I've got a 'data' folder with some images and dwg files I want to include with the compiled project.

For some reason, I'm having the darndest of times getting visual studio to add it to the output directory. My google-fu has failed me, I've tried what stack overflow says (outside of build events), but can't 'Copy to Output Directory'. That option is available for other files in the project though.

I'm using VS Community 2015. The folder (and contents) are added to the project, but I can't find where to add it to the output directory, it's not in the properties dialog where it kinda should be.

With resources, I can see how to add individual files, but not whole folders. I know it's not  strictly a CAD related programming issue, but though you guys might be able to help.

Any ideas?

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: Adding a data folder to my .NET project to be included with build
« Reply #1 on: September 13, 2018, 02:23:28 AM »
The way I do this is with build event commands like:

copy "$(TargetDir)*.dll" "C:\My Folder\Data\"

This will copy all dll's in the build output directory to a folder on my c drive.
You should be able to find examples of copying folder etc and remember to add the commands to each build config you need to.

hth
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: Adding a data folder to my .NET project to be included with build
« Reply #2 on: September 13, 2018, 07:06:15 AM »
right click the folder and pick "Include in project".  Then on each image you can select properties and choose copy to output directory.
Revit 2019, AMEP 2019 64bit Win 10

JohnK

  • Administrator
  • Seagull
  • Posts: 10605
Re: Adding a data folder to my .NET project to be included with build
« Reply #3 on: September 13, 2018, 07:50:25 AM »
I also use the same method MickD does.

Also, I had written a post/tut where I copied a file over--using a custom tool I wrote--and changed some text in the file based on the build in case you'd need that operation as well.
https://www.theswamp.org/index.php?topic=50241.msg554012#msg554012
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Atook

  • Swamp Rat
  • Posts: 1027
  • AKA Tim
Re: Adding a data folder to my .NET project to be included with build
« Reply #4 on: September 13, 2018, 12:34:09 PM »
Thanks guys, looks like I'll go the build event route.

MC, that's what I did, now when I right click, I can 'exclude from project' but I can't set it to copy to build directory. Weird.

Thanks all.