How to copy files to the MSVC 2010 output directory

> Coding, hacking, computer graphics, game dev, and such...
User avatar
fips
Site Admin
Posts: 166
Joined: Wed Nov 12, 2008 9:49 pm
Location: Prague
Contact:

How to copy files to the MSVC 2010 output directory

Post by fips »

It's a typical task that one needs to automatically copy a 3rd party file (e.g. a DLL library) to the project's output directory as a post-build step. Here's how it can be achieved in Microsoft Visual Studio 2010 (MSBuild). Let's assume we have a file structure like this:

Code: Select all

.../External/glew_1_5_5/lib/glew32.dll (source)
.../Game/Game.vcxproj (project file)
.../Game/{Debug or Release}/glew32.dll (destination)
It's quite simple, we just need to edit 'Game.vcxproj' and add the following lines to the end:

Code: Select all

<Project>
 ...
 <!-- BEGIN --> 
 <Target Name="AfterBuild" >  
  <Copy SourceFiles="..\..\External\glew_1_5_5\lib\glew32.dll" DestinationFolder="$(OutDir)"></Copy>  
 </Target>
 <!-- END -->
</Project>