1

Is there a way that whenever I compile my project in Visual Studio it will create the exe file in the project directory and also copy the exe file to a different directory?

Is Visual using a makefile that I can edit and add the copying command to it? Thanks!

T.G.
  • 743
  • 3
  • 6
  • 27

1 Answers1

2

You'll want to open up your Project Properties (just select the project and press Alt + Enter) From there go to: "Configuration Properties" > "Build Events" > "Post-Build Event" and edit the "Command Line" property: enter image description here There you'll what to use the $(Target Path) macro to get the generated executable. So you're "Command Line" property will probably look something like this:

mkdir "Lorem Ipsum"
copy "$(Target Path)" "Lorem Ipsum"

Incidentally this can also be accomplished in an AfterBuildEvent In you .vcprojx file. If you're interested you can read more here: MSBuild AfterBuild Step

Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
  • 1
    Also, it could be worth to delete that copied file in Pre-Build Event so that you can understand the copied target is latest successful build for sure (because if your build fails you may find you with obsolete copy). – Yury Schkatula Apr 12 '18 at 13:07
  • @YurySchkatula That would be my preference as well but I'll leave that to the discretion of the OP. Some people prefer to be able to run old builds even when the current build fails. – Jonathan Mee Apr 12 '18 at 13:30