I have two projects, one VB6 project which compiles to an EXE and one MSVC++2010 project which compiles to a DLL. The DLL needs to be in the same folder as the EXE file in order to work. Can I have Visual Studio 2010 automatically copy the compiled DLL to the VB6 project folder after a compilation?
4 Answers
The easiest way to set this up is to use a post build event. These run once a build is successfully completed and has a set of handy macros to make access to common outputs, like compiled files, very easy
For example. Here are the steps to a compiled DLL / EXE into c:\temp
- Right Click on the Project and select "Properties"
- Click on the Build Events Tab
- Add the following line to the "Post-Build" box:
copy "$(TargetPath)" c:\temp
In the above $(TargetPath)
is a macro for the primary output of a build task: typically the EXE or DLL file. If you click on the "Edit Post Build" button, then macros you can see the full list of supported macros.

- 11,595
- 1
- 35
- 66

- 733,204
- 149
- 1,241
- 1,454
-
To copy multiple files at once: **`xcopy /s /y "c:\source" "d\target"`**. Has difficulties with macros though. – Bitterblue Apr 02 '14 at 06:52
-
1if your $(TargetPath) has spaces in it you need to use quotes. I just spent 10 minutes figuring this out the hard way. [copy "$(TargetPath)" c:\temp] @JaredPar would you mind updating? editing existing accepted answers that are 99% perfect is something I would like to avoid. – Semicolons and Duct Tape Apr 27 '16 at 19:19
-
I had the same issue with not having the quotes. So i went ahead and edited the answer. – Black Frog Dec 04 '16 at 19:22
I believe you're asking for Post Build Events
An example of what you want to do, I believe, can be found here

- 4,689
- 2
- 26
- 44
Is Project > Configuration Properties > Build Events > Post-Build Event what you are looking for? With a command line of something like copy <dllpath> <dest>

- 1,002
- 1
- 12
- 22
Visual Studio has pre and post build events that you can use to accomplish what you want to do.
just go to Project: "project name" properties you should see a tab named build events. There you should be able to create Macros to do it for you.
Hope this helps.

- 13
- 3