Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2010: how to automatically copy files into debug directory

I've got a dll, into which I've inserted txt files into the names subdirectory enter image description here

When I build the solution, VS does not create the directory and does not copy the files themselves into the directory of the exe file, which references the dll library

Is there an easy way to make it do that?

like image 478
Arsen Zahray Avatar asked Feb 08 '12 00:02

Arsen Zahray


People also ask

How do you make a copy of a DLL to the output directory in Visual Studio?

Use a post-build action in your project, and add the commands to copy the offending DLL. The post-build action are written as a batch script. The output directory can be referenced as $(OutDir) . The project directory is available as $(ProjDir) .

What is Copy to Output Directory?

"Copy to Output Directory" is the property of the files within a Visual Studio project, which defines if the file will be copied to the project's built path as it is. Coping the file as it is allows us to use relative path to files within the project.


1 Answers

It should do that, provided that you have a reference for the class library project in your executable project. I just setup a scenario like this in Visual Studio 2010:

  1. Created a C# Console Application project
  2. Created a C# Class Library project
  3. Added a Reference to the C# Class Library project into the Console Application project.
  4. Added a folder to the C# Class Library project called 'Files'
  5. Added a Text File to the 'Files' folder called 'File1.txt'
  6. Set the Text File 'File1.txt' 'Copy to Output Directory' property to 'Copy Always'
  7. Did a 'Build Solution' and looked in the bin directory of my Console Application and low and behold there was a folder called 'Files' and within it, a file called 'File1.txt'

Maybe you are missing a project reference to your class library in your exe?

like image 52
codechurn Avatar answered Sep 21 '22 03:09

codechurn