17

I need my C# project to launch another EXE program during execution. This executable needs to be placed in the same folder as the C# program is placed on building the solution, for example, the debug folder -- just like DLL file references -- so that when my team members check the project out from TFS, and debug, the EXE is found when my C# code tries to call it.

However, the EXE is not a reference per se, and so it cannot be added as a reference, even though I want it to be copied around in the same manner as a reference.

Is there a reasonable solution for this problem?

Thanks in advance.

John
  • 565
  • 1
  • 6
  • 18
  • 1
    You can package the EXE with your c# program when you are ready to release it with an installer, but I know that wasn't your actual question. – JNYRanger Sep 10 '13 at 20:45

4 Answers4

29

You can go the properties of the file, and under Copy to output Directory select, copy if newer

enter image description here

Habib
  • 219,104
  • 29
  • 407
  • 436
5

You could add the executable as item to your C# project and in its properties set its Copy to Output Directory property to Copy always. This way the executable will be copied to the output folder (bin\Debug or bin\Release) everytime you compile your project.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
2

Create a batch file that is performing the copy action after the build. It is possible to do other stuff pre-build and post build. See http://msdn.microsoft.com/en-us/library/ke5z92ks.aspx

TheHube
  • 752
  • 1
  • 10
  • 23
  • Vote for this because if you use this exe in different solutions you can replace only one file and all solutions will use the new one. – neutron Sep 11 '13 at 06:55
1

Package the .exe with the setup of your program.

Just add it to the Applications Folder. Its the same as it being in the bin/Debug folder.