简体   繁体   中英

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!

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

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\"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM