Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy exe from one project to another's debug output directory

I have two projects, ProjOne.exe and ProjTwo.exe. I want to build ProjOne.exe and it know that it's dependant on ProjTwo.exe so that it will copy ProjTwo.exe when it goes to build ProjOne.exe.

I also have a ProjThree.dll that it already does that for perfectly. But this in only because the dll is referenced by ProjOne.

Any way to do this like it does with DLLs/OCXs? Or is this going to be some POST build scripting? :) If so please give examples of the script I would use.

Thanks!

like image 305
Arvo Bowen Avatar asked Mar 08 '16 18:03

Arvo Bowen


2 Answers

Go to Project ProjTwo Properties -> Build Events --> Post-build event command line :

echo f | xcopy /y "$(TargetPath)" "$(SolutionDir)ProjOne\bin\Debug$(TargetFileName)"

When you build ProjTwo, then it copies ProjTwo.exe to Debug folder of ProjOne

like image 79
ganchito55 Avatar answered Oct 10 '22 17:10

ganchito55


I ended up using ganchito55's method and it worked great. I then quickly realized that it would not suit my purposes when dealing with multiple files (such as debug files, etc). I also wanted to account for building in DEBUG and RELEASE.

I ended up doing the following...

1) Dig down to the project properties on ProjTwo:

Right click on project -> Properties -> Build Events

2) Add the following lines to the "Post-build event command line" box:

Copy ALL files used in the ProjTwo to the ProjOne output directory when building DEBUG output.

if $(ConfigurationName) == Debug xcopy /y "$(TargetDir)*.*" "$(SolutionDir)ProjOne\bin\Debug\"

Copy ALL files used in the ProjTwo to the ProjOne output directory when building RELEASE output.

if $(ConfigurationName) == Release xcopy /y "$(TargetDir)*.*" "$(SolutionDir)ProjOne\bin\Release\"
like image 45
Arvo Bowen Avatar answered Oct 10 '22 17:10

Arvo Bowen