将exe从一个项目复制到另一个项目的调试输出目录

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

我有两个项目,ProjOne.exe 和 ProjTwo.exe。我想构建 ProjOne.exe 并且它知道它依赖于 ProjTwo.exe 因此它会在构建 ProjOne.exe.

时复制 ProjTwo.exe

我还有一个 ProjThree.dll,它已经完美地做到了。但这只是因为该 dll 被 ProjOne 引用。

有什么方法可以像 DLLs/OCXs 那样做到这一点?或者这将是一些 POST 构建脚本? :) 如果是这样,请举例说明我将使用的脚本。

谢谢!

转到 Project ProjTwo 属性 -> 构建事件 --> Post-构建事件命令行 :

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

构建 ProjTwo 时,它会将 ProjTwo.exe 复制到 ProjOne

的 Debug 文件夹

我最终使用了 ganchito55 的方法并且效果很好。然后我很快意识到在处理多个文件(例如调试文件等)时它不适合我的目的。我还想考虑 DEBUGRELEASE.

中的构建

我最终做了以下事情...

1) 深入了解 ProjTwo 上的项目属性:

右键单击项目 -> Properties -> Build Events

2) 将以下行添加到 "Post-build event command line" 框中:

在构建 DEBUG 输出时,将 ProjTwo 中使用的所有文件复制到 ProjOne 输出目录。

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

在构建 RELEASE 输出时,将 ProjTwo 中使用的所有文件复制到 ProjOne 输出目录。

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