TheSwamp

Code Red => .NET => Topic started by: Atook on September 12, 2018, 04:53:42 PM

Title: Adding a data folder to my .NET project to be included with build
Post by: Atook 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?
Title: Re: Adding a data folder to my .NET project to be included with build
Post by: MickD 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
Title: Re: Adding a data folder to my .NET project to be included with build
Post by: MexicanCustard 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.
Title: Re: Adding a data folder to my .NET project to be included with build
Post by: JohnK 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
Title: Re: Adding a data folder to my .NET project to be included with build
Post by: Atook 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.