0

I made a library which uses .xml files for configuration. But in the core project, which use this library, ressources are not copied. I added a reference to my library.dll but of course there is nothing that says i need to include /configuration folder of the lib project.

How can i achieve that ? (manual copy is excluded)

ps: im working in c# with visual studio 2012 ultimate. both project are c#. One generate a library (dll etc..), other is executable project.

Thanks in advance :)

MinionKing
  • 187
  • 1
  • 4
  • 20

1 Answers1

0

Right click and select Add > Existing item to include the resources into your project.

After including them, select them under the Solution Explorer, right click and select properties. Look for Copy to Output Directory, and set it to Always. That should copy the files along with your project.

Another option if needed, may be to set Build Action to Embedded Resource, but that might make it a little more complicated (but not impossible) to access the files from your application.

Update: Accessing a file that is embedded is a little more messy, but this other SO question might help you out.

Community
  • 1
  • 1
Kjartan
  • 18,591
  • 15
  • 71
  • 96
  • My ressource are correctly copied in the /release or /debug folder, it's working as expected for the lib project. The issue is : When i include this library into an another project, it didn't copy .xml files. So in the another project i have a IOexception because there is not file anymore :s – MinionKing Apr 04 '14 at 09:13
  • Im pretty sure if i copy, by hands, the /configuration folder of my lib projecto into the /release folder of the core project, it would work. But i don't want to do this, by hands:s – MinionKing Apr 04 '14 at 09:17
  • Ok.. Then I suspect you might need to use my second option: If you include the files as embedded resources, they should be included _in_ the `.dll`, and so you should be able to access them from the second project too. – Kjartan Apr 04 '14 at 09:18
  • This way, i lost all the benefit of having a configuration file in xml which i can modify without having to rebuild whole project:s edit : plus i use this .xml files for configuration which i can modify from code or by hand , depend on situation. If it's embbeded in the .dll, i could serialize again those file ( well i think). Am i correct ? – MinionKing Apr 04 '14 at 09:36