1

I have a solution which contains a few projects and an external exe. When I build, I want to copy the exe to my build folder, as well as build the projects and copy my dlls to the build folder. Is there any way to run this external exe as my post-build event? So, when I run my solution in visual studio, I would like to basically set the external exe as the startup project. Is this possible (or something similar)?

Stefan Paul Noack
  • 3,654
  • 1
  • 27
  • 38
steve
  • 223
  • 1
  • 4
  • 15

2 Answers2

5

You don't want to run it while building, you want to run it when you start debugging. First get the .exe copied to the build directory with Project + Add Existing Item. Select the .exe. Set its Copy to Output Directory property to "Copy if newer". Build + Rebuild.

Then select it as your startup EXE with Project + Properties, Debug tab. Select the "Start external program" radio button and select the .exe in your bin\debug directory. Press F5 to get it going with the debugger attached.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • +1 I use to copy the EXE in the post-build event, but project-item with copy to output is even neater. – Albin Sunnanbo Dec 21 '11 at 20:33
  • All of my projects are independent of each other, what would I do in this case? – steve Dec 21 '11 at 20:51
  • I have no idea what that means. The settings I documented are a per-project setting. You select the project you want to run by right-clicking it and selecting "Set as startup project". – Hans Passant Dec 21 '11 at 20:53
  • Each of my projects builds an assembly, and the executable uses these assemblies. I guess I could just have a "dummy" project that does what you said. I'll try that. – steve Dec 21 '11 at 20:59
1

Add the EXE to your project as a file. right click the EXE properties. set "Copy to Output Directory" to "Copy Always"

Then in the properties of your project, under the Debug tab, set start external program and pick your EXE.

M3NTA7
  • 1,307
  • 1
  • 13
  • 25