问题
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!
回答1:
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
回答2:
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\"
来源:https://stackoverflow.com/questions/35874812/copy-exe-from-one-project-to-anothers-debug-output-directory