Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Visual Studio copy a DLL file to the output directory?

I have a Visual Studio C++ project that relies on an external DLL file. How can I make Visual Studio copy this DLL file automatically into the output directory (debug/release) when I build the project?

like image 454
Mat Avatar asked Nov 21 '09 17:11

Mat


People also ask

How do I copy output in Visual Studio?

Copy to Output Directory is a property for files within a Visual Studio project. Select a Windows Form in a project, find Copy to Output Directory and note Copy to Output Directory is set to [Do not copy].

How do I change the output path in Visual Studio?

Right-click on the project node in Solution Explorer and select Properties. Expand the Build section, and select the Output subsection. Find the Base output path for C#, and type in the path to generate output to (absolute or relative to the root project directory), or choose Browse to browse to that folder instead.


1 Answers

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). Try to use relative pathes where applicable, so that you can copy or move your project folder without breaking the post-build action.

like image 115
Adrien Plisson Avatar answered Oct 06 '22 05:10

Adrien Plisson